How to select records between a date to another date given a DateTime field in a table.
Here, first add a day to the current endDate, it will be 2011-02-28 00:00:00 , then you subtract one second to make the end date 2011-02-27 23:59:59 . By doing this, you can get all the dates between the given intervals.
SELECT * FROM PERSONAL WHERE BIRTH_DATE_TIME BETWEEN '2001-03-01 11:00:00' AND '2005-03-01 22:00:00';
date and time. For example instead of between '02/03/2011' and '05/03/2011' it should be between '02/03/2011 00:00:01' and '05/03/2011 23:59:59' ... Date AND Time.
SELECT *
FROM tbl
WHERE myDate BETWEEN #date one# AND #date two#;
select *
from blah
where DatetimeField between '22/02/2009 09:00:00.000' and '23/05/2009 10:30:00.000'
Depending on the country setting for the login, the month/day may need to be swapped around.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With