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

How do you order by date?

Status
Not open for further replies.

sjf

Technical User
Jan 1, 2001
56
AU
This may seem like a stupid question but how do you order a recordset by date?

I have a database that stores the date in the following format:
Field 1 - Day
Field 2 - Month
Field 3 - Year

I want to be able to sort this using an SQL query, anyone got any ideas?
 
Select field1,field2,field3 from table_name order by field3 desc,field2 desc,field1 desc

This will sort recordset by year(from latest to earliest), then within each year - by month(from latest to earliest) and at last - within each month - by day(from latest to earliest)
 
if the month is jan or january dont forget to use the

month(month_field) to get the right order.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top