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!

Number to Date

Status
Not open for further replies.

cgordonn

MIS
Nov 21, 2001
9
US
I have searched the forums for information on converting a number date type to a date, but have not found a solution for my problem. The database I am working with stores the date as follows, or at least this is how CR 8.5 shows the number date in the report...

Example 1
Actual Date: 09/24/1985
In Crystal: 9,241,985.00 (9 digits)

Example 2
Actual Date: 10/03/1985
In Crystal: 10,031,985.00 (10 digits)

As shown in the examples, the number dates are either 9 or 10 digits in length. I know how to remove the comma's, decimal point and trailing zeros from the number, which would leave me with either a 7 or 8 digit number (or string). The number to date formula examples I have come accross in Crystal all deal with 2 digit months (in my examples it would be 09 or 10). My month varies from either 1 to 2 digit months, which causes the report to error.

Does anyone have some advise on how to deal with this month digit problem?

Thanks!
CGordonn
 
either use :

Local StringVar NumDate := ToText(10031985,0,"");
If Len(NumDate) = 7 then
Date(Picture(NumDate,"0x/xx/xxxx")) else
If Len(NumDate) = 8 then
Date(Picture(NumDate,"xx/xx/xxxx"));

replacing the item in bold with your field name, or download the number to date ufl from
Reebo
UK

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
In Basic syntax:

Dim D As Number
'
D = 10031985.00

Formula = Mid(ToText(D,"00000000"),1,2) + "/" + Mid(ToText(D,"00000000"),3,2) + "/" + Mid(ToText(D,"00000000"),5,4)

This works for either 9 or 10 digit dates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top