Focal Point
Date conversion question

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3321068331

May 24, 2005, 11:49 PM
<Nathan>
Date conversion question
I am receiving cycle as parameter and want
to set value of amper variable "var" to var1 or
var2 based on whether it is current month or
not.
The cycle is passed in form of '05/2005' string
('MM/YYYY').

The following code returns syntax error message
for IF .. THEN statement.

0 ERROR AT OR NEAR LINE 25 IN PROCEDURE _ADHOCRQFOCEXEC *
(FOC266) IF .. THEN .. ELSE .. SYNTAX ERROR

I need to convert the current date properly
to alpha format ? How ?
Any other elegant solution ?

Thanks

-*===========================================
-SET &DT01 = AYMD(&YYMD,0,'I8YYMD') ;
-SET &M01 = EDIT(&DT01,'$$$$99$$') ;
-SET &Y01 = EDIT(&DT01,'9999') ;
-SET &M02 = &M01 | &Y01 ;
-SET &CURR01 = EDIT(&M02,'99/9999') ;
-*
-SET &cycle01 = &cycle; <-- Parameter received
-*
-* Following statement gives error
-*
-SET &var = IF &CURR01 EQ &cycle01
THEN 'var01' ELSE 'var02';
-TYPE &var
-EXIT
-*============================================
May 25, 2005, 12:14 AM
drew billingslea
Your original di not contain a '-' on the second line of the -SET. All continued lines in Dialog Manager need a - in the first column.

You might also try:

-*===========================================
-SET &CDT = &DATEM || '/' || &DATEYY ;
-SET &DV = IF &CDT CONTAINS &CYCLE
- THEN 'V1' ELSE 'V2';

-TYPE &DV
-EXIT
-*============================================

for some reason I was getting a space at the beggining of &CDT so I changed the EQ to CONTAINS in the &DV comparison.

hth,

drew
May 25, 2005, 12:19 AM
drew billingslea
sorry; just tried it on WebFOCUS 5.2.5 and this code:

-*===========================================
-SET &CDT = &DATEM || '/' || &DATEYY ;
-SET &DV = IF &CDT EQ &CYCLE
- THEN 'V1' ELSE 'V2';

-TYPE &DV
-EXIT
-*============================================


worked fine.

drew
May 25, 2005, 01:25 PM
<Nathan>
Thanks Drew for your timely help.