Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Date String to Date 2

Status
Not open for further replies.

RobMcP

Technical User
Jul 25, 2005
6
GB
Hi there,

I am trying to convert a date string (YYYYMMDD) to a date (DDMMYY). Using the following formula, I have met with partial success, the day and the year pull through correctly for each entry but the month is always (01).

E.g. (20011031 = 31/01/2001) or (20011201 = 01/01/2001) or (20031208 = 08/01/2003)

My formula is as follows.
Code:
//Convert The Status Changed Date

NumberVar xy := tonumber(Left({AUT001.Date Status Last Changed},4));
NumberVar xd := Day(Datevalue (tonumber(Right({AUT001.Date Status Last Changed},2))+1));
NumberVar xm := Month(Datevalue (tonumber(Mid({AUT001.Date Status Last Changed},5,2))+1));

Date(xy,xm,xd)
I am using Crystal 10 and I’m totally stumped.

Any help would be very much appreciated, thanks in advance.
 
You were nearly there, just over egged the pudding slightly

Code:
//Convert The Status Changed Date

NumberVar xy := tonumber(Left({AUT001.Date Status Last Changed},4));
NumberVar xd := tonumber(Right({AUT001.Date Status Last Changed},2));
NumberVar xm := tonumber(Mid({AUT001.Date Status Last Changed},5,2));

Date(xy,xm,xd)

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Try

NumberVar xy := tonumber(Left(({AUT001.Date Status Last Changed},4));
NumberVar xd := tonumber(Right(({AUT001.Date Status Last Changed},2));
NumberVar xm := tonumber(Mid(({AUT001.Date Status Last Changed},5,2));

Date(xy,xm,xd)

Mo
 
Cheers guys that worked perfectly.

Rob
 
Glad you got it sorted and thanks for the star.

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top