Focal Point
Reformatting a date.

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

June 16, 2009, 08:27 AM
TomG
Reformatting a date.
Hi,

I am trying to do something rather simple and
am having problems with it.

I want to reformat a character date value from a YYYYMMDD format to another character type date value that is in a MM/DD/YYYY format.

Thank you in advance.

Tom


WebFOCUS 7.6.7
Linux
csv/.txt, pdf, Excel
June 16, 2009, 11:14 AM
TomG
With assistance from a co-worker, I have my answer. Hopefully the below will help someone having a
similar challenge.

-> to convert the alpha date from YYYYMMDD to MMDDYYYY... targetDateField/A8=CHGDAT('YYMD', 'MDYY', sourceDateField, 'A8');

-> to introduce the date separators... formattedDate/A10=EDIT(targetDateField, '99/99/9999');


WebFOCUS 7.6.7
Linux
csv/.txt, pdf, Excel
June 16, 2009, 05:38 PM
Waz
Being an alpha field you could have also use EDIT.
targetDateField/A8=EDIT(sourcedateField,'99/99/') | EDIT(sourcedateField,'$$$$9999'); 



Ooops got the format wrong.

As per Madhumitha's post

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


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

June 17, 2009, 01:28 AM
Madhumitha
hi,
you want to convert a character date value from yyyymmdd to chatacter date value of mm/dd/yyyy right, then the following code will help you.

targetfield/A10=EDIT(inputfield, '$$$$99/99/')|EDIT(inputfield, '9999')

it will convert yyyymmdd format to character date of mm/dd/yyyy correctly

Eg: inputfield =20080301
then outputfield=03/01/2008

Regards,
Madhu

This message has been edited. Last edited by: Madhumitha,
June 17, 2009, 07:49 AM
trob
TomG,
If you are going to be dealing with dates often I would recommend that you get use to working with the DATECVT(DATE-FIELD,'IN-FORMAT','OUT-FORMAT') function.

Anytime I'm dealing with dates I seem to require moving to and from smartdates or expressing my date in a format other than what has supplied from my data.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
June 18, 2009, 01:20 AM
Madhumitha
Waz,
What wrong format you got according to my post???
June 18, 2009, 01:31 AM
Waz
Just saying that my original post had the format of the date wrong, where yours was right


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 14, 2011, 12:34 PM
Ted Michalski
AAARGH. I've tried everything I can think of. Nothing works.

I have a field in the database defined as A10. The actual data in the field is 9/30/2011
I want to convert this to 2011-09-30.
How can I do this?


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
October 14, 2011, 02:05 PM
Ted Michalski
Never mind. I don't need this afterall.


7.7.02
Windows
EXCEL, PDF, CSV, TEXT