Links Programming SQL

Comparing Date Range (Date Interaction checking through SQL)

As title says, I was looking to compare User give date range with date range saved in mysql Database. I search internet and found a great  small function that solve this problem for me, though they create a function for some programming language but I use same function in mysql (as per mysql syntax) and its all done

select * from  TableName where
(‘2008-04-16’ = start_date) or
if((‘2008-04-16’ > start_date),(‘2008-04-16′<=end_date),(start_date<=’2008-08-20’))

here 2008-04-16 is user enter date, and 2008-08-20 is user end end date for date range I collect from web form, and start_date and end_date is field in my table that define date range.

you can read about function here

By Sumit Gupta

Sumit Gupta, born on 7th Feb 1981 in NCR, India. He lives a quiet life until he turn to a developer. Once he is in his professional life people start recognizing him for his work. Sumit Gupta is always keen to learn more and share his knowledge to anyone who deserve it. His goal of life is to code at least one 3D action game by itself or with his company Vikasumit [].

2 replies on “Comparing Date Range (Date Interaction checking through SQL)”

Comments are closed.