Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

HelpMe me To Calculate Hours



  • Please log in to reply
3 replies to this topic
snowmind
  • Members
  • 43 posts
  • Last active: Dec 19 2019 02:39 PM
  • Joined: 04 Oct 2012

Hi Everyone,

 

 

I'm trying to resolved a problem with autohotkey to calculated hours.

In this example:

 

 

Var=14/10/15 02:13:38 ;# My tool always take the time in this format #
StringTrimLeft, Var, Var, 9 ;# I remove the date to take onyl hour. This time, a variable Var is: 02:13:38
EnvAdd, Var, 15 ,Minits ;# I think here is problem....I dont understand how to add minutes. Is the right?
FormatTime, Var  ;# Format the time....
MsgBox, Value: %Var% ;# Unfortunally, is wrong the result

 

 

The result should be 02:28:38 ;# With 15 minutes add

Someone to help me?

 

 



gilliduck
  • Members
  • 109 posts
  • Last active: Nov 09 2015 01:07 AM
  • Joined: 19 Dec 2013

Two things, one you spelled minutes wrong in the EnvAdd, other than that, it's correct. The issue is the actual time. 02:13:38 is not a valid format for math, you need to convert it to HHMMSS (021338) to do anything to it. I'd recommend a StrSplit on the :'s and the rejoin the broken string, do your math, then if you need to view it in a more friendly format, either manually split it again or use FormatTime.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012
✓  Best Answer

^7::
Var=14/10/15 02:13:38 ;# My tool always take the time in this format #
StringTrimLeft, Var, Var, 9 ;# I remove the date to take onyl hour. This time, a variable Var is: 02:13:38
StringReplace, Var, Var,:,,All ; Removes the :'s
Var:="20150101" Var ; makes it a YYYYMMDDHH24MISS timestamp
EnvAdd, Var, 15, Minutes ;# 15 minute are added to the YYYYMMDDHH24MISS timestamp
FormatTime, Var, %Var%, HH:mm:ss ; Formats the time into 02:28:38
MsgBox, Value: %Var% ;# Hopefully, this is the right result
return

 

Working with EnvAdd and manipulating strings can be tricky.



snowmind
  • Members
  • 43 posts
  • Last active: Dec 19 2019 02:39 PM
  • Joined: 04 Oct 2012
^7::
Var=14/10/15 02:13:38 ;# My tool always take the time in this format #
StringTrimLeft, Var, Var, 9 ;# I remove the date to take onyl hour. This time, a variable Var is: 02:13:38
StringReplace, Var, Var,:,,All ; Removes the :'s
Var:="20150101" Var ; makes it a YYYYMMDDHH24MISS timestamp
EnvAdd, Var, 15, Minutes ;# 15 minute are added to the YYYYMMDDHH24MISS timestamp
FormatTime, Var, %Var%, HH:mm:ss ; Formats the time into 02:28:38
MsgBox, Value: %Var% ;# Hopefully, this is the right result
return

Working with EnvAdd and manipulating strings can be tricky.

 

 Oh really things...Its work fine
 Thanks a lot