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!

Bad Date Format String 1

Status
Not open for further replies.

retygh45

IS-IT--Management
May 23, 2006
166
US
Using CR11, I have a string field that stores a date in the format 20070907

I'm simply trying to turn this string into a date so I can report off it, but when I do: Cdate({table.field})

I get an error of "Bad Date Format String". Any ideas as to what would be causing this? Thanks!

 
nervmind, I found a post with what I was looking for:

//@convert to date
local stringvar input := "20060628"; //replace with your field
date(val(input[1 to 4]),val(input[5 to 6]),val(input[7 to 8]))

Thanks!
 
Your formula has limitations as it is a print time formula (uses variables) and cannot be used for grouping. So just write a simpler formula:

Date(val({YourField}[1 to 4]),val({YourField}[5 to 6]),val({YourField}[7 to 8]))

You might also look at the NumberToDate() function which is specifically designed to take an 8 digit number in a YYYYMMDD format and convert it to a real date. This is a UFL download found here:



Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If the phone doesn't ring, it's me".....Jimmy Buffet
 
Actually, you could group on the formula, as it does not use "whileprintingrecords" and the variables are not shared variables. Variables are not automatically unavailable for grouping.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top