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

Converting number to Date ( data coming from AS400) 1

Status
Not open for further replies.

old123

MIS
Jun 1, 2005
31
US
Iam using CR ver 9 to pull data off from AS400 . date field come over as a numeric (eg. 50601 which is 1st june 2005 )I need to convert this number 50601 to date 06/01/2005. i was trying to use numbertodate function which i downloaded from other site but did'nt work. Any help ........Iam new to crystal reports
 
Try something like this, which uses a combination of the Mod and Int functions to break apart portions of the number field to represent year, month, and day:

//I'm using the variable 'dt' for clarity...
NumberVar dt := {Table.NumericDateField};
Date(Int(dt/10000) + 2000, Int((dt Mod 10000) / 100), dt Mod 100)

Are all of your years 2000 or greater?

-dave
 
i tried this formula CDate(ToNumber(Left(CStr(50601, 0), 1)) + 2000, ToNumber(mid(CStr(50601, 0), 2, 3)), ToNumber(Right(CStr(50601, 0), 2)))

it worked. as all the years & in 2000. Thanks
 
This NumbertoDate({YourNumber}+20000000) worked too.

this is easy one. thank you guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top