June 01, 2007, 12:30 PM
UsernaniHow can I compare time
I need to compare the time so that if it is GE 17:00:00 or LE 24:00:00 then display as 'non prime' else as 'prime'.
My table has a Date field which is in HYYMDm format and I extracted the time portion by using HHIS format. But still I cannot compare.
Please Help!
June 01, 2007, 02:13 PM
GlendaHere a work around until someone comes up with something better.
Convert your Date field to alpha using HCNVRT.
Next extract out the time with the EDIT function.
Then compare the times with an IF statement.
Example:
DEFINE FILE CAR
TODAY/YYMD = &YYMD;
C_DATE_TIME/HYYMDm = HGETC(10, 'HYYMDm');
A_DATE_TIME/A30 = HCNVRT(C_DATE_TIME, '(HYYMDm)', 30, 'A30');
A_TIME/A8 = EDIT(A_DATE_TIME, '$$$$$$$$$$$99999999');
TIMETYPE/A9 = IF A_TIME GE '17:00:00' AND A_TIME LE '24:00:00' THEN 'non prime' ELSE 'prime';
END
TABLE FILE CAR
PRINT
C_DATE_TIME
A_DATE_TIME
A_TIME
TIMETYPE
COUNTRY
CAR
MODEL
ON TABLE PCHOLD FORMAT EXL2K
END
-EXIT
Glenda
June 01, 2007, 03:10 PM
UsernaniThanks Glenda, it works. I just eliminated the EDIT step as we can directly extract the time using 'HHIS' format instead of 'HYYMDm' while using HCNVRT function.
Thanks for your help