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

Converting date to string then sort 2

Status
Not open for further replies.

NewB2007

Technical User
Feb 25, 2008
42
US
I have a report that a user can select what they would like to group the report by. By doing this grouping the sort is automatically set. I have all string options then one date. when I try set up my function if the user selects a date crystal XI won't all me to have the date. Here is what my function looks like:

if {?option} = 'String' then (database string field) else
if {?option} = 'String' then (database string field) else
if {?option} = 'String' then (database string field) else
if {?option} = 'String' then (database date field) else

it is the date field that is stopping me. So I convert to a string

if {?option} = 'String' then cstr((database date field)) else

But when I do that the report will no longer sort as if this was a date field. If I simply tell the report to group by the date field only it works fine. But when I make that date a string crystal quits working...

Hopefully I am explaining this clearly enough. Let me know if you need more!

Thanks!!
 
What do you mean it quits working?

You need to set the date format as follows to get the correct sort:

totext({table.date},"yyyy-MM-dd")

-LB

 
You are leading me down the right trail here. But when I go to change the date to text I get something strange.

totext({table.date}, "yyyy-mm-dd")

I get back 2000-mm-18

I tried to switch it around like so

totext({table.date}, "yyyy-dd-mm")

I get back 2000-18-mm

Any other ideas?

Also now the sort is kind of working but not as I would like it to. It sorts by the year and nothing else. So basically it will group all of the dates together but then will show as this

2000-mm-18

2000-mm-15

2000-mm-22

2000-mm-10

I have to have the dates showing in complete decending order!

2000-mm-10
2000-mm-15
2000-mm-18
2000-mm-22
 
The case matters. You have to use "yyyy-MM-dd".

-LB
 
Picky! Picky!

Worked like a charm!

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top