Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,


My table contains "date of birth" column in (DD/MM/YYYY) Like (10/09/2011) Format now i want to get records of 07Th month to find the information of users who Born in 07Th month Can any one send query



Thanks & regards

Janareddy.M
Posted

Use DATEPART see here : http://msdn.microsoft.com/en-us/library/ms174420.aspx[^]

SQL
select * from tablename where DATEPART(mm, datecol) = 7 
 
Share this answer
 
Comments
RaisKazi 31-Oct-11 5:47am    
My 5. :)
Mehdi Gholam 31-Oct-11 6:01am    
Thanks
Amir Mahfoozi 2-Nov-11 7:00am    
+5
Mehdi Gholam 2-Nov-11 7:02am    
Thanks
use month function as
SQL
select * from tablename where month(dob)='7'
 
Share this answer
 
Comments
RaisKazi 31-Oct-11 5:49am    
My 5. :)
janareddyjanareddy 31-Oct-11 5:57am    
Thank you dear
janareddyjanareddy 31-Oct-11 6:00am    
Getting error

Conversion failed when converting date and/or time from character string.
uspatel 31-Oct-11 6:24am    
Thanks raisKazi
Member 7932936 31-Oct-11 6:09am    
It's really very useful solution
Thanks
User MONTH() on the date you want to select and query.
 
Share this answer
 
Use this:

SQL
select * from tablename where DATEPART(mm, dateofbirth) = 7 ;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900