October 05, 2005, 06:05 AM
<We_Focus> Convert Date Format
Hi All
I Have a DATE parameter which passes the value
in MDYY format
I want to convert the value into I8MDYY format
I have tried this but its not giving proper values
DEFINE TABLE SALES
RSDATE/I8MDYY=DTMDY(&RS_DATE, RSDATE);
REDATE/I8MDYY=DTMDY(&RE_DATE, RSDATE);
END
Thanks in Advance
We_Focus
October 05, 2005, 07:01 AM
Dharma Have you used DATECVT command? i guess it works.
RSDATE/I8MDYY = DATECVT(RS_DATE, 'MDYY', 'I8MDYY');
October 05, 2005, 08:04 AM
<We_Focus> Hi Dharma
The RS_DATE is a parameter not a field and i tried that it did not worked
RSDATE/I8MDYY = DATECVT(&RS_DATE, 'MDYY', 'I8MDYY');
If my Parameter value is 09/09/2005 then it returns 12/31/1900
thanks for Reply
We_Focus
October 05, 2005, 12:59 PM
codermonkey DM variables (&RS_DATE) can either be alpha or numeric. They can not be smart dates. That is why the DTMDY function isn't working. The function expects the first value to be smart date and it isn't. If the value of &RS_DATE is 09092005 (without slashes) you can define it right to I8MDYY. If it does have slashes, you can do it in 2 steps:
-SET &RS_DATE1=0902005;
-SET &RS_DATE2='09/09/2005';
-*
DEFINE FILE SALES
RSDATE1/I8MDYY = &RS_DATE1;
TEMP1/MDYY = '&RS_DATE2';
RSDATE2/I8MDYY = TEMP1;
END
October 05, 2005, 01:05 PM
jimster06 Here is some code that I have used to convert mm/dd/yyyy format dates to standard dates:
-SET &DATE01 = '09/05/2005'; -SET &DTLEN = &DATE01.LENGTH; -SET &YY01 = GETTOK(&DATE01,&DTLEN,-,'/',4,'A4'); -SET &MM01 = GETTOK(&DATE01,&DTLEN,-,'/',2,'A2'); -* strip out / -SET &MM02 = &MM01 + 100; -SET &MM01 = EDIT(&MM02,'$99'); -SET &DD01 = GETTOK(&DATE01,&DTLEN,-,'/',2,'A2'); -SET &DD02 = &DD01 + 100; -SET &DD01 = EDIT(&DD02,'$99'); -* make sure that months < Oct have a leading zero -SET &DATE02 = &YY01 | &MM01 | &DD01; -* above is integer -SET &DATE03 = DATECVT(&DATE02,'I8YYMD','YYMD'); -* DATE03 is standard format date HTH
This message has been edited. Last edited by: <Maryellen>, November 12, 2005 11:34 PM October 05, 2005, 01:11 PM
codermonkey Had a quick thought. This should work too:
-SET &RS_DATE2='09/09/2005';
DEFINE FILE SALES
RS_DATE2/I8MDYY = EDIT(EDIT('&RS_DATE2','99$99$9999'));
END