[SOLVED]Change the date format from DD-MON-YY format to MM/DD/YY format
Hi,
I have a field/column having the value as 18-AUG-16 and today it shows as this date and few days later,it might show a different date value(I mean this field's value is dynamic)which is in A12 format and I need to display it in MM/DD/YY(8/18/16) format but Iam unable to achieve it.
I tried CHGDAT,HINPUT etc but nothing seems to be working.
Could anyone please help me on this.
Any help is appreciated.Thanks a lot in advance!
Thanks, IPThis message has been edited. Last edited by: info4pal,
I'm afraid there isn't a function that does this automatically. So, you can write your own:
DEFINE FUNCTION INFO4PAL (INFO/A12)
AMON/A3=EDIT(INFO,'$$$999');
MON/A2=DECODE AMON(JAN 01 FEB 02 MAR 03 APR 04 MAY 05 JUN 06 JUL 07 AUG 08 SEP 09 OCT 10 NOV 11 DEC 12);
ADATE/A6MDY=MON | EDIT(INFO,'99') | EDIT(INFO,'$$$$$$$99');
INFO4PAL/MDY=ADATE;
END
DEFINE FILE CAR
INFO/A12='19-AUG-16';
DATE/MDYY=INFO4PAL(INFO);
END
TABLE FILE CAR
PRINT INFO DATE
BY COUNTRY
END
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
This DATETRAN function can just as easily be used in a DEFINE as well...
WebFOCUS 8105m Windows 7, All Outputs
Member of the Benelux Usergroup
August 19, 2016, 08:03 AM
info4pal
Hi,
Thanks Swes and Danny for the inputs but this is not the expected result which Iam looking for
This is the piece of code which Iam using:
TABLE FILE REPORT1 PRINT DATE_FLD1 DATE_FLD2 HEADING "DATE_FLD1 WHICH IS IN MM/DD/YY" ENDSTYLE END
The date fields DATE_FLD1 and DATE_FLD2 are in A12V format. When I run my report,I will get the result in 02-JUL-16 but I need to print it in the Heading as 07/02/16 format.Could you or anyone please help me to achieve it.
In any case you will need to transform the ALPHA field to a smart date, from there you can have it in any format you like... and also put that field in the heading using HEADING "
WebFOCUS 8105m Windows 7, All Outputs
Member of the Benelux Usergroup
August 19, 2016, 08:42 AM
Danny-SRL
SWES,
You will still have to DECODE the month (unless I'm mistaken). Once you have done that, IMHO the 2 assignments should be "cheaper" than the use of 2 functions.
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
August 19, 2016, 08:45 AM
Danny-SRL
quote:
TABLE FILE REPORT1 PRINT DATE_FLD1 DATE_FLD2 HEADING "DATE_FLD1 WHICH IS IN MM/DD/YY" END
DEFINE FUNCTION INFO4PAL (INFO/A12)
AMON/A3=EDIT(INFO,'$$$999');
MON/A2=DECODE AMON(JAN 01 FEB 02 MAR 03 APR 04 MAY 05 JUN 06 JUL 07 AUG 08 SEP 09 OCT 10 NOV 11 DEC 12);
ADATE/A6MDY=MON | EDIT(INFO,'99') | EDIT(INFO,'$$$$$$$99');
INFO4PAL/MDY=ADATE;
END
DEFINE FILE REPORT1
MYDATE/MDY=INFO4PAL(DATE_FLD1);
END
TABLE FILE REPORT1 PRINT DATE_FLD1 DATE_FLD2
HEADING
"DATE_FLD1 WHICH IS IN <MYDATE"
END
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
August 22, 2016, 09:40 AM
info4pal
Thank you very much SWES and Danny. It helped a lot and it worked too