Compare two times

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

kszynkar
Posts: 45
Joined: Tue Feb 02, 2016 1:15 am
Location: Switzerland

Compare two times

Postby kszynkar » Thu May 05, 2016 7:09 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Compare two times

Postby EViews Gareth » Thu May 05, 2016 8:00 am

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.

kszynkar
Posts: 45
Joined: Tue Feb 02, 2016 1:15 am
Location: Switzerland

Re: Compare two times

Postby kszynkar » Thu May 05, 2016 11:20 pm

I needed to test it to the minute at least, but can use this way. Thanks


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest