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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conversion to a Date Format

Status
Not open for further replies.

TEM3

Technical User
Dec 6, 2004
324
US
Using Crystal Reports 8.5 and Oracle 9i tables:

I have a bunch of "dates" in a text table field that Crytal Reports is incapabible of converting with the todate function. They are all in the format of, for example, 26FEB2008.

Any suggestions for a formula that would convert a intended date like "26FEB2008" to "02/26/2008"? What these record field all have in common is that they are 9 characters long and all start with two digits (in string form).
 
Are you sure ToDate won't convert them? Try
Code:
ToText(ToDate({your.date}), "MM/dd/yyyy")
I no longer have 8.5, maybe that version fails. If so, use Left, MID and RIGHT to split the day, month and year and to convert. FEB = 2 etc and re-assemble using Date(yyyy, mm, dd)

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
This formula seems to works.....

if len(trim({ARRESULTASVARCHAR.RESULTASVARCHAR})) = 9 then

(
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "JAN" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "FEB" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "MAR" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "APR" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "MAY" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "JUN" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "JUL" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "AUG" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "SEP" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "OCT" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "NOV" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4)) else
if Mid({ARRESULTASVARCHAR.RESULTASVARCHAR},3 ,3) = "DEC" then ("01/" & Left({ARRESULTASVARCHAR.RESULTASVARCHAR},2) & "/" & Mid ({ARRESULTASVARCHAR.RESULTASVARCHAR},6 ,4))
);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top