Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to fetch all the records which have the birthday within a date range.
Posted
Comments
Sergey Alexandrovich Kryukov 14-Apr-14 1:06am    
What have you tried so far?
—SA

This is an example of showing birthdates between 1-nov to 15 dec of this year

SQL
select distinct  Birthdate  from T_staff where Birthdate between cast(cast(11 as varchar)+'-'+cast(1 as varchar)+'-'+cast(year(getdate()) as varchar) as datetime) and cast(cast(12 as varchar)+'-'+cast(15 as varchar)+'-'+cast(year(getdate()) as varchar) as datetime)
 
Share this answer
 
v2
Comments
Member 10746762 14-Apr-14 5:46am    
Thanks!!!
Kabi Pr. Sahoo 14-Apr-14 6:22am    
welcome...
 
Share this answer
 
Comments
Member 10746762 14-Apr-14 1:24am    
It works,but i need to fetch it without passing year..Based only on Day and Month it should be fetched.
Sergey Alexandrovich Kryukov 14-Apr-14 1:59am    
What does it mean, "without passing year"?
—SA
Here I have given a simple example.Please go through it.

SQL
select Birthdate from T_staff where Birthdate between fromdate and todate 
 
Share this answer
 
Comments
Member 10746762 14-Apr-14 1:23am    
It works,but i need to fetch it without passing year..Based only on Day and Month it should be fetched.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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