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

convert a number to a date

Status
Not open for further replies.

simoncs

Technical User
Jul 8, 2004
5
AU
Hi

I am trying to convert a number to a date in crystal reports 8.5


the field is a "floating field" on the oracle database - which i believe is similar to a number field?

the numbers for the most part is formatted as ddmmyy and so appears on the report as 150106 - i would like to be able to have this as a date so that we can format it accordingly - eg 15-Jan-2006.

The other problem seems to be that sometimes for dates less than 10 there are only 5 numbers eg 50106.


thanks

Simon
 
Yeah, seems OK still, try:

whileprintingrecords;
Datevar MyDate:=trim(totext({table.field},0,""));
// replace table.field above with yours //
if len(trim(MyDate)) = 5 then
cdate(val(mid(MyDate,4,2)),val(mid(MyDate,2,2)),val(left(MyDate,1)))
else
if len(trim(MyDate)) = 6 then
cdate(val(mid(MyDate,5,2)),val(mid(MyDate,3,2)),val(left(MyDate,2)))
else
cdate(0,0,0)

Should get you close.

-k
 
thanks - but it produces an error when trying to save the formula

"A date is required here"

cursor then rests at end of - Datevar MyDate:=


any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top