IB - Developer Center    Forums  Hop To Forum Categories  iWay Products    Reformatting a date.
Go
New
Search
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
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: 28 | Registered: June 01, 2009Reply With QuoteReport This Post
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: 28 | Registered: June 01, 2009Reply With QuoteReport This Post
Waz
Virtuoso
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.1.6Upgrade:WebFOCUS 7.6.6OS:UnixOutputs:PDF, CSV, Excel, TXT, XML, HTML

 
Posts: 1534 | Location: Sydney, Australia | Registered: October 31, 2006Reply With QuoteReport This Post
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: 3 | Registered: September 30, 2008Reply With QuoteReport 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 7.6.11
WFS 7.6.11
I-Way for iSeries
 
Posts: 69 | Location: Atlanta | Registered: May 10, 2007Reply With QuoteReport This Post
Member
Posted Hide Post
Waz,
What wrong format you got according to my post???
 
Posts: 3 | Registered: September 30, 2008Reply With QuoteReport This Post
Waz
Virtuoso
Posted Hide Post
Just saying that my original post had the format of the date wrong, where yours was right


Waz...
Prod:WebFOCUS 7.1.6Upgrade:WebFOCUS 7.6.6OS:UnixOutputs:PDF, CSV, Excel, TXT, XML, HTML

 
Posts: 1534 | Location: Sydney, Australia | Registered: October 31, 2006Reply With QuoteReport This Post
  Powered by Social Strata  
 

IB - Developer Center    Forums  Hop To Forum Categories  iWay Products    Reformatting a date.

Copyright © 1996-2010 Information Builders, leaders in enterprise business intelligence.