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!

How convert my date?

Status
Not open for further replies.

vcavusoglu

Programmer
Apr 26, 2001
41
TR
I am using MS-SQL SERVER 2000, VB6, CR8
a field is datetime and "01.05.2001 00:00:00"
and this field is as group
I am to view this field "01 May 2001 Tuesday"

How ?

Thanks.
 
The basic formula is like this:


Date(
Val({field} [ 7 to 10 ] ),
Val({field} [ 4 to 5 ] ),
Val({field} [ 1 to 2 ] ) )


You can then format this date field however you like. You might need to do some error checking to make sure that dates aren't blank or don't have invalid values. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
If Crystal Reports recognizes the field as a datetime type field, then you can format this field to appear in wide variety of pre-existing formats, or create a custom format of your own.
If Crystal Reports recognizes the field as a string type field, then you could convert the string to a date, and then pick the format option you want for the date. Normally this would just be DateValue({yourdatetimestringfield}), but since the "." character is not recognized as a valid date separator, you would need to replace the "." with "/".
DateValue( Replace({yourdatetimestringfield}, ".", "/") )
This method may be preferable, especially in situations where the datetime string varies in length, or you expect to encounter blank (empty string) values.
Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top