Focal Point
[SOLVED]Change the date format from DD-MON-YY format to MM/DD/YY format

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

August 19, 2016, 06:26 AM
info4pal
[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,
IP

This message has been edited. Last edited by: info4pal,


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
August 19, 2016, 07:05 AM
SWES
Do you have a snippet of code for us?

Try change it to a smart date with a two or maybe three step define:

1) NEWFIELDA/A8YYMD = DATE;
2) NEWFIELDB/YYMD = NEWFIELDA;
3) NEWFIELDC/[ desired format ] = NEWFIELDB;

or maybe it would even work as:

1) NEWFIELDA/A8YYMD = DATE;
2) NEWFIELDB/[ desired format ] = NEWFIELDA;


WebFOCUS 8105m
Windows 7, All Outputs

Member of the Benelux Usergroup
August 19, 2016, 07:07 AM
Danny-SRL
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

August 19, 2016, 07:19 AM
SWES
Danny, then I would definitely prefer to use:

-SET &MDYY  = DATETRAN(DATECVT(&YYMD,'I8YYMD','MDYY'), '(MDYY)', '(t-)', 'EN', 16, 'A16');

-TYPE &MDYY


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 Frowner

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.

Thanks a lot in advance!

Regards,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
August 19, 2016, 08:28 AM
SWES
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 Smiler


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML