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 9:00AM on 21-Sep-2010.
Any ideas as to how the query should be?
This question is related to
sql-server-2008
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'
use DBName
select * from TABLE_NAME A
where A.date >= '2018-06-26 21:24' and A.date <= '2018-06-26 21:28';
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
You can try this:
SELECT * FROM MYTABLE WHERE DATE BETWEEN '03/10/2014 06:25:00' and '03/12/2010 6:25:00'
SELECT * FROM TABLE
WHERE DATE BETWEEN '09/16/2010 05:00:00' and '09/21/2010 09:00:00'
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 Applicant.applicantId, Applicant.lastName, Applicant.firstName, Applicant.middleName, Applicant.status,Applicant.companyId, Company.name, Applicant.createDate FROM (Applicant INNER JOIN Company ON Applicant.companyId = Company.companyId) WHERE Applicant.createDate between '" +dateTimePicker1.Text.ToString() + "'and '"+dateTimePicker2.Text.ToString() +"'";
this is what i did!!
Source: Stackoverflow.com