How do I write a SQL query for a specific date range and date time using SQL Server 2008?

前端 未结 8 443
刺人心
刺人心 2021-01-04 01:33

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

相关标签:
8条回答
  • 2021-01-04 02:07
    "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!!

    0 讨论(0)
  • 2021-01-04 02:09

    Infact this worked for me

     SELECT * 
     FROM myTable
     WHERE CAST(ReadDate AS DATETIME) + ReadTime BETWEEN '2010-09-16 5:00PM' AND '2010-09-21 9:00AM'
    
    0 讨论(0)
提交回复
热议问题