I need to write a query that will get all the rows in a specified date range and time range.
For example, I want to query all the rows from 5:00PM on 16-Sep-2010 to
use DBName
select * from TABLE_NAME A
where A.date >= '2018-06-26 21:24' and A.date <= '2018-06-26 21:28';
Remember that the US date format is different from the UK. Using the UK format, it needs to be, e.g.
-- dd/mm/ccyy hh:mm:ss
dbo.no_time(at.date_stamp) between '22/05/2016 00:00:01' and '22/07/2016 23:59:59'
How about this?
SELECT Value, ReadTime, ReadDate
FROM YOURTABLE
WHERE CAST(ReadDate AS DATETIME) + ReadTime BETWEEN '2010-09-16 17:00:00' AND '2010-09-21 09:00:00'
EDIT: output according to OP's wishes ;-)
SELECT * FROM TABLE
WHERE DATE BETWEEN '09/16/2010 05:00:00' and '09/21/2010 09:00:00'
You can try this:
SELECT * FROM MYTABLE WHERE DATE BETWEEN '03/10/2014 06:25:00' and '03/12/2010 6:25:00'
DATE(readingstamp) BETWEEN '2016-07-21' AND '2016-07-31' AND TIME(readingstamp) BETWEEN '08:00:00' AND '17:59:59'
simply separate the casting of date and time