Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name.


Connect to myibi

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Reformatting a date.
 Login/Join
 
Silver Member
posted
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
 
Posts: 31 | Registered: June 01, 2009Report This Post
Silver Member
posted Hide Post
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
 
Posts: 31 | Registered: June 01, 2009Report This Post
Expert
posted Hide Post
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!

 
Posts: 6349 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Gold member
posted Hide Post
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,
 
Posts: 53 | Registered: September 30, 2008Report This Post
Gold member
posted Hide Post
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
 
Posts: 86 | Location: Atlanta | Registered: May 10, 2007Report This Post
Gold member
posted Hide Post
Waz,
What wrong format you got according to my post???
 
Posts: 53 | Registered: September 30, 2008Report This Post
Expert
posted Hide Post
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!

 
Posts: 6349 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
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
 
Posts: 106 | Registered: June 25, 2009Report This Post
Platinum Member
posted Hide Post
Never mind. I don't need this afterall.


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders