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

Problem with cdate - Bad String format

Status
Not open for further replies.

humour

Programmer
Nov 24, 2003
87
In CRYSTAL version8.5, I am trying to convert a string date which is an 8 byte string field like "20040406", by using CDATE ({PURCHASE1.PO_DATE}) and all I keep getting is "Bad date format string"

CDate("20040224") returns the same error...

Any help appreciated.
 
It's expecting a string like "2/24/2004" or "Feb 24, 2004".

Try using a formula like this (will probably throw errors if it encounters NULLs, so you might want to incorporate some checking):

CDate(Val(Left({PURCHASE1.PO_DATE},4)) , Val(Mid({PURCHASE1.PO_DATE},5,2)), Val(Right({PURCHASE1.PO_DATE},2)))

-dave
 
I don't know if this would work for you, but I use DTSToDate ({filename.DATE_TIME}) I realize it's for a date and time string, but it works with just a date string as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top