sarayucm
sarayucm

Reputation: 126

Check month and day lies between two dates

I have two fields which stores month and day separately. I have a requirement where I need to check the month and day fields(in the format MM/DD) should lie between two dates. For example, if I have month and day fields stored as (02/11), then if the user passes from and to dates as 02/11/2012(MM/DD/YYYY) to 02/28/2014, then I need get that record(02/11).

Kindly provide your inputs on how to achieve this in T-Sql or SQL Server.

Upvotes: 0

Views: 519

Answers (1)

Dudi Konfino
Dudi Konfino

Reputation: 1136

FOR SQL SERVER 2012

   IF (select  CONCAT(month,'/',day)) 
FROM tbl) between LEFT(date1,5) and LEFT(date2,5)
BEGIN 
PRINT CONCAT(month,'/',day) 
END

Upvotes: 1

Related Questions