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

Convert number to date format in CR XI !!

Status
Not open for further replies.

lpbruce1

MIS
Aug 2, 2004
15
0
0
US
I need to be able to convert an 8 digit number field (example: Number (20051208) to date field 12/08/2005) to a Date field in Crystal Reports XI. Is this possible without having to break the number apart and then puting them in the correct order and then coverting to a date.

I know for CR 7 and lower there is a Number to Date UFL that can be downloaded from Business Objects that will use a function called

numbertodate()

But I dont know if this UFL will work for CR XI and if so, where do you put the .dll's ? In the Readme file from BO it says to copy the .dlls to the windows\crystal folder but in CRXI there is not windows\crystal folder.

Any suggestions?

Thanks
lpbruce1

 
The UFL might work, but it isn't required.

Plus you can probably get the database to do it by using a SQL Expression, which would prove the most efficient, but since you ask about fixing data and not share your database type nor version, it's hard to assist you on that level.

Formula:

stringvar MyDate:= {table.field};
cdate(val(left(MyDate,4)),val(mid(MyDate,5,2)),val(mid(MyDate,7,2)))

-k
 
You can also use this formula to convert an 8 digit number to date format.

WhilePrintingRecords;
NumberVar input := {DATE}; // or whatever your field name is

// This line checks for a minimum value, any value will work.
If input < 19590101 then Date (1959, 01, 01) else
Date ( Val (ToText (input, 0 , "") [1 to 4]),
Val (ToText (input, 0 , "") [5 to 6]),
Val (ToText (input, 0 , "") [7 to 8]) )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top