Technical support and scripting issues
Moderators: Dorian (MJT support), JRL
-
Danish_Ken
- Junior Coder
- Posts: 22
- Joined: Mon Sep 12, 2005 1:34 am
- Location: Melbourne - Australia
Post
by Danish_Ken » Wed Mar 24, 2010 5:52 am
Following sample works fine on my PC (24 hour format of course), but when attempted on a 12 hour AM/PM PC, the comparison doesn't work.
Is there any other way of achieving this?
24 hour
Code: Select all
GetTime>TimeNow
Let>EarlyTime=09:30:00
Let>LateTime=18:00:00
If>{(%TimeNow% > %EarlyTime%) AND (%TimeNow% < %LateTime%)}
MDL>Within allowed time
Else
MDL>Outside allowed time
Endif
12-hour
Code: Select all
GetTime>TimeNow
Let>EarlyTime=9:30:00 AM
Let>LateTime=6:00:00 PM
If>{(%TimeNow% > %EarlyTime%) AND (%TimeNow% < %LateTime%)}
MDL>Within allowed time
Else
MDL>Outside allowed time
Endif
Thanks
/Ken
Macro Scheduler since Version 5.0 - 21/10/1998
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Wed Mar 24, 2010 9:09 am
Don't use GetTime.
Use Hour, Min and Sec commands which always return numbers corresponding to the current hour, minute and second and always return the hour in 24 hour format. Therefore you can never go wrong. They are not influenced by regional settings:
Hour>hh
Min>mm
Sec>ss
Let>TimeNow=%hh%%mm%%ss%
Let>EarlyTime=093000
Let>LateTime=180000
If>{(%TimeNow% > %EarlyTime%) AND (%TimeNow% Within allowed time
Else
MDL>Outside allowed time
Endif
Using If>{(%TimeNow% > %EarlyTime%) AND (%TimeNow% Within allowed time
Else
MDL>Outside allowed time
Endif
GetTime will return a string of the short time format specified in regional settings. You can't therefore use it in numeric comparisons unless you wish to parse it. No point. Use Hour, Min & Sec functions.
-
Danish_Ken
- Junior Coder
- Posts: 22
- Joined: Mon Sep 12, 2005 1:34 am
- Location: Melbourne - Australia
Post
by Danish_Ken » Wed Mar 24, 2010 9:56 pm
Thanks Marcus, and as always thanks for the speedy reply.
/Ken
Macro Scheduler since Version 5.0 - 21/10/1998