Jump to content
Macro Express Forums

Time between times


randallf

Recommended Posts

Hello! Running into a logic problem here that I just don't think I have the knowledge to solve:

 

I have two sets of variables that represent times

 

Specificially these are: (example)

 

ex

12:01 PM

 

Set one: N1:N3 T1 - let's say, when the timer goes off (when my case expires SLA)

 

and

 

Set two: N31:N32 T33 - the current time

 

(where T1 and T33 are set to AM or PM as necessary)

 

 

Can anyone provide me a function for getting the hours and minutes between these times and telling me if it is already past that time?

 

I basically want to know how long until the timer goes off, or have it tell me if it should already have gone off... the amount of time between N31:N32 T33 and N1:N3 T1... whatever those might be.

 

 

 

We can assume the same day for all times... the only consideration is between AM and PM... There will never be a PM time BEFORE an AM time but the reverse is of course true as that is the point of the function!

 

THANK YOU!!! :)

Link to comment
Share on other sites

Convert both times to minutes, for example using N91 for current time,

N91 = (N31 X 60) + N32

if T33 = PM

N91 = N91 + 720 [720 is number of minutes in 12 hours]

end if

 

Then you can directly compare the minutes variables to see whether timer has been passed or not.

 

Subtract current minutes from timer minutes to see how long until the timer "goes off".

To convert it to hours and minutes, just divide by 60 to get hours, and the remainder is minutes.

For example, if N99 is minutes remaining, then hours remaining N98 is

N98 = N99 / 60

and minutes over the hours N97 is

N97 = N99 - (N98 * 60)

Link to comment
Share on other sites

The macro I am working with is HUUUGE... over 640 lines now...

 

Here is the function that I made but it doesn't work right. Probably the AM/PM crap messing me up.

 

I'm ganna rewrite the thing from scratch using 24 hour formats within the program... basically whenever the macro mines any data and stores variables it will convert it at that time to 24 hour format, use only 24 hour format in calculations and export in 24 hour format. It's a sacrifice I'm very willing to make at this point.

 

HOWEVER thank you very much for the helpful info, I learned a lot by working with this.

 

 

Text Type: CALCULATE EXPIRY DURATION

Variable Modify Integer: %N33% = %N31% * 60

Variable Modify Integer: %N33% = %N33% + %N32%

Variable Modify Integer: %N34% = %N1% * 60

Variable Modify Integer: %N34% = %N34% + %N3%

If Variable %T33% = "PM"

Variable Modify Integer: %N33% = %N33% + 720

End If

 

If Variable %T1% = "PM"

Variable Modify Integer: %N34% = %N34% + 720

End If

 

If Variable %N34% > variable %N33%

Variable Set String %T9% "NOT EXPIRED"

 

Variable Modify Integer: %N35% = %N34% - %N33%

 

Variable Modify Integer: %N36% = %N35% / 60

 

Variable Modify Integer: %N37% = %N36% * 60

 

Variable Modify Integer: %N38% = %N35% - %N37%

 

.... and some comments and End If

Link to comment
Share on other sites

Have you looked at the 'Date Time', 'Date Time Difference Calculator', 'Macro Timer' and 'Time Code Calculators' on our Shared Macros page? One of these sample macros may contain what you need.

 

Thanks Kevin, but I *think* it is just so much simpler in 24 hour format that not to just use 24 hour is crazy...

 

Can it really be this simple?!?!

 

Format:

01:23 PM

N1:N2 T1

 

(edit... guess i needed an AM function)

Convert to 24 hour:

If Variable %T1% = "PM"
 If Variable %N1% < 12
Variable Modify Integer: %N1% = %N1% + 12
 End If
End If
If Variable %T1% = "AM"
 If Variable %N1% = 12
Variable Set Integer %N1% to 00
 End If
End If

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...