How to select records from last 24 hours using SQL?

后端 未结 11 2152
Happy的楠姐
Happy的楠姐 2020-12-04 04:41

I am looking for a where clause that can be used to retrieve records for the last 24 hours?

11条回答
  •  清歌不尽
    2020-12-04 05:38

    Which SQL was not specified, SQL 2005 / 2008

    SELECT yourfields from yourTable WHERE yourfieldWithDate > dateadd(dd,-1,getdate())
    

    If you are on the 2008 increased accuracy date types, then use the new sysdatetime() function instead, equally if using UTC times internally swap to the UTC calls.

提交回复
热议问题