Click here to Skip to main content
15,881,801 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have a table which has three colums..

HTML
id  | startdate   | enddate
1   |'2014-01-02' |'2014-01-05'


If suppose i query a date as '2014-01-03', it should fetch a rows which is in between the start date and end date...


Please anyone can help me.. Thanks in advance..
Posted
Comments
King Fisher 14-Feb-14 4:05am    
not clear.

SQL
SELECT * FROM MyTable WHERE '2014-01-05' BETWEEN startdate AND enddate

Note that is will only work when you are using DATE or DATETIME columns in your database. If you are using text, change them - it's a very poor idea!
 
Share this answer
 
Try this way.
SQL
SELECT *
FROM table_1
WHERE '2014-01-03' between startdate
AND enddate
 
Share this answer
 

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