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

convert numeric date to date 2

Status
Not open for further replies.

JRine0101

Programmer
Feb 4, 2005
5
US
I have a field in my database that is defined as a numeric field but it is a date in format yyyymmdd. I would like to display it as "mm/dd/yyyy".

First choice is to convert it to a date so I can do whatever formatting I want, but it would make me happy just to have be able to display it as I previously described.
 
Converting to a Date would be the easiest way to deal with this. Here's one way to do it:

NumberVar dt := {Table.DateAsNumberField};
NumberVar yr := Int(dt/10000);
NumberVar mo := Int((dt Mod 10000)/100);
NumberVar dy := dt Mod 100;
Date(yr,mo,dy);

-dave
 
Numbertodate({YYYYMMDD field}) works very well. NumberToDate() is a UFL which you may ned to download depending on your version of Crystal.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
That sounds good, but apparently I do need to download it. Where do I get it?
 
Wouldn't this work???

Date (val({TABLE.DATEFIELD}[1 TO 4]),val({TABLE.DATEFIELD}[5 to 6]),val({TABLE.DATEFIELD[7 to 8]))

(Then just apply CR's date formatting. Right Click, Format Field, Date tab)

-- Jason
"It's Just Ones and Zeros
 
The UFL for Numbertodate can be downloaed from the BO support site.

Cheers
Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top