Page 1 of 1

Compare two times

Posted: Thu May 05, 2016 7:09 am
by kszynkar
Hi,

I was wondering how to compare two times. I would like to do something similar to:

Code: Select all

if @dateval("17:00")<@now then

Re: Compare two times

Posted: Thu May 05, 2016 8:00 am
by EViews Gareth
The syntax you're using will work just fine. The problem is, what is "17:00"? That isn't a date/time. Do you want to tell whether the time right now is less than 17:00 today? If so, I think the easiest way is just:

Code: Select all

if @datepart(@now, "hh")<17) then
Note that only works because you're testing for an exact hour. If you wanted 17.30, it would be more tricky.

Re: Compare two times

Posted: Thu May 05, 2016 11:20 pm
by kszynkar
I needed to test it to the minute at least, but can use this way. Thanks