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

Numeric Date to Actual Date

Status
Not open for further replies.

TheMagikWand

Technical User
Aug 11, 2003
35
US
hey guys/gals, im kinda new at this so this may seem like an easy Q but ive got no where else to turn. i have a field of dates listed in 6 digit number codes:

May 1st 2003 is listed as 050103

i would like them to show up on the report as the written form (May 1st 2003)

any ideas??????


thanx
 
Try:

//Any numeric date stored as MMDDYY could be 50103.
//This checks if a 0 needs to be added at the start.
Local StringVar NumericDate := totext(50103,0,"");
If Len(NumericDate) = 5 then NumericDate := "0"&NumericDate;
date(mid(NumericDate,3,2)&"/"&left(NumericDate,2)&"/"&mid(NumericDate,5))

and replace the item in bold with your field name.

Reebo
Scotland (Sunny with a Smile)
 
Or a neater approach may be to use the NumberToDate function e.g. NumberToDate({Table.Field}). This function is contained in the UFL Ufltdate.dll, if you need to search for it on Crystal's website. Once your formula has converted the number to a date, simply format it to appear how ever you want.

Peter Shirley
 
It can't be a number given that your your example shows it starting with an 0.

Also consider using a SQL Expression for this if you intend to use it in any table filtering.

In CR try:

cdate(mid({table.textdate},5,2)+"/"+left({table.textdate},2)+"/"+mid({table.textdate},3,2))

Now that it's a date field, you can place it on the report, right click it and select format field->Date and get exactly what you want.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top