Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to order birth dates by day

Author  Topic 

krainov
Yak Posting Veteran

57 Posts

Posted - 2009-09-24 : 17:18:18
Hi there!
I have an array of person details with the date of birth from DB. I need to order them by Day in month. I meen if I will Order them as "ORDER BY DateOfBirth" I will get them in oder of the years (12/08/1950, 15/08/1972, 11/08/1980). But I want them to list as (11/08/1980, 12/08/1950, 15/08/1972) independed on the year.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-09-24 : 17:48:39
ORDER BY DATEPART(DAY, DateOfBirth), DATEPART(MONTH, DateOfBirth), DATEPART(YEAR, DateOfBirth) DESC




N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

krainov
Yak Posting Veteran

57 Posts

Posted - 2009-09-24 : 17:55:18
Thank You Peso!
You have saved my time again...
Go to Top of Page
   

- Advertisement -