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!

Need Date Field to Sort by Date, Not Number

Status
Not open for further replies.

cmhdover

Technical User
Jul 15, 2004
37
US
I have Crystal Reports 8.0 and I think this is a simple fix. When I sort my date field it sorts by month instead the entire date. For example, 1/5/06 comes before 3/19/04. I want earliest date to most recent date.

Thanks!

Dennielle
 
Then it's not a date field, or you've specifically asked it to sort by month only, I'll asssume the first.

Just because data appears to be a specific data type doesn't mean that it is, it' up to you as the developer to understand data types and convert them when required.

If you right click the field and select browse data, it will tell you the data type. If it says string, then it's a string which houses a mask of a date, it is NOT a date.

So create a formula of:

cdate({table.date}) and sort by it.

btw, when you sort a string it sorts by the order of the characters within, hence your mistaken assumption that it is sorting by month, it is not, you'll see that October will follow January as they both start with a 1.

-k

-k

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top