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

Problem converting date/time string to date string

Status
Not open for further replies.

Jonesxx

Technical User
Jul 14, 2004
71
GB
Hi,

I am using Crystal 8.5 and I am trying to convert the field cont.hist (which is a date/time string) into only a date string.

The formula I have used is:



IF DTSToDateTime ({CONTHIST.CREATEON}) then DTSToDate ({CONTHIST.CREATEON})Else 0


I keep on getting an error saying that a string is required. Any ideas?


Thanks v m
 
Sorry I made a mistake, I'm trying to convert the date/time value so that the Conthist.Createon field is only a date type.
 
If it's already a datetime, then you can just use:

date({Conthist.Createon})

-LB
 
Convert datetime to a varchar(8), e.g. @Date varchar (8)
I've done it in the stored procedure behind the Crystal report.
 
The fastest metod would be a SQL Expression on the database using a CAST or CONVERT, providing your database has a DATE type (for instance SQL Server does not). You didn't bother to post your database type so I can't supply the syntax.

Otherwise Lbass's solution should work for you.

-k

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top