Devin Posted July 2, 2015 Posted July 2, 2015 I thought this issues was going to be simple, but it turns out woking with time is something I've not been able to wrap my head around. Can someone please tell me what is wrong with doing this. If ( Get ( CurrentTime ) > "12:00:00 AM"; If ( Get ( CurrentTime ) < "03:00:00 AM" ; "TRUE" ; "FALSE" ) ; "FALSE" ) What I'm trying to do is find out if the the current time falls between two different times in the day. I want to know if the current time is between 12am and 2:59 AM and return a True or False statement..
eos Posted July 2, 2015 Posted July 2, 2015 want to know if the current time is between 12am and 2:59 AM and return a True or False statement.. Use Time() to construct a value that you can safely compare to Get ( CurrentTime ): Get ( CurrentTime ) > Time ( 0 ; 0 ; 0 ) and Get ( CurrentTime ) < Time ( 3 ; 0 ; 0 ) is True or False; no need to use If(). Note also that "True" and False" is merely text; the keywords True and False are written without quotes.
Raybaudi Posted July 2, 2015 Posted July 2, 2015 "12:00:00 AM" and "03:00:00 AM" aren't times, but strings.Use Time ( 12 ; 0 ; 0 ) and Time ( 3 ; 0 ; 0 ) instead.
Devin Posted July 2, 2015 Author Posted July 2, 2015 Use Time() to construct a value that you can safely compare to Get ( CurrentTime ): Get ( CurrentTime ) > Time ( 0 ; 0 ; 0 ) and Get ( CurrentTime ) < Time ( 3 ; 0 ; 0 ) is True or False; no need to use If(). How does it know the difference between AM an PM? Are we to use the 24 hour clock if needed. Thanks for the help..
Devin Posted July 2, 2015 Author Posted July 2, 2015 Perfect.. Looks like this is working. Thanks four you help.
comment Posted July 2, 2015 Posted July 2, 2015 (edited) I want to know if the current time is between 12am and 2:59 AM and return a True or False statement.. Well, if the exact midnight can be included in the range, then you could simplify your test to: Get ( CurrentTime ) < Time ( 3 ; 0 ; 0 ) or, if you prefer: Get ( CurrentTime ) < 10800 as the current time will never be negative. Edited July 2, 2015 by comment
Recommended Posts
This topic is 3488 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now