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

Converting String to Date

Status
Not open for further replies.
Dec 16, 2008
83
GB
Crystal Xi

Hi. I've got a list of dates that are stored as strings and would like to convert them all to a date. I was thinking about using:

cdate({@Policy Docs Sent})

However, when i flick through my report i get this error:

Bad date, format string

What does this mean? Is this because say there is a day 30 in the month of Feb? How can i get round this or is there anything else i can do?
 
YOU can filter out duff dates

If IsDate(datestring) Then
CDate(datestring)
Else
CDate(0,0,0)

Ian


 
You are an absolute legend, cheers mate, and thanks for the quick response
 
Hi,

If your dates look like this '22/07/1971' (it has /s) then Date('22/7/1971') should work to convert it to a date.
If your dates look like this '22071971' without the / then Date ('22071971') won't work in which case we can use a formula to put the / back into the date.

See example below:
//assuming a date called {OrderDate} that looks like this'22071971'
StringVar DateFixed:= {OrderDate} [1 to 2]& '/'& {OrderDate} [3 to 4] &"/"& OrderDate [5 to 8];
date({DateFixed})

If this isn't the problem can you email a couple of examples of what your string dates look like

Tx

Gordon BOCP
Crystalize
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top