Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding date between start date and end date

Tags:

sql

mysql

I want to check whether a date is between start date and end date.

i have added a where clause

where datepaid between '2010-04-01' AND '2010-04-15'

but the problem is that it excludes '2010-04-15'.

It should include end date also how can i do this?

Please help me on this

Regards,

pankaj

like image 619
Pankaj Khurana Avatar asked Dec 02 '22 05:12

Pankaj Khurana


2 Answers

Specify the time parts explicitly:

WHERE datepaid BETWEEN '2010-04-01 00:00:00' AND '2010-04-15 23:59:59'
like image 152
LukeH Avatar answered Dec 04 '22 01:12

LukeH


Perhaps your dates include intraday times. Try this instead:

where '2010-04-01' <= datepaid AND datepaid < '2010-04-16'
like image 45
Marcelo Cantos Avatar answered Dec 03 '22 23:12

Marcelo Cantos