Search code examples
sql-serverdatetimegetdatesql-server-2008r2-expresssysdatetime

How to Check Valid Date Time from Sql Table


I want to check either my current DateTime is between two DateTimes or not.

I have first time 2016-05-19 04:23:00.000 and second time 2016-05-19 04:50:00.000.

How to write a query to return true if current DateTime is between first and second time else return false?


Solution

  • Select *
    From Table
    Where
      ( '2016-05-19 04:23:00.000' <= dateColumn )
      And ( dateColumn < '2016-05-19 04:50:00.000' )