How to select records from last 24 hours using SQL?

后端 未结 11 2149
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:12

    In SQL Server (For last 24 hours):

    SELECT  *
    FROM    mytable
    WHERE   order_date > DateAdd(DAY, -1, GETDATE()) and order_date<=GETDATE()
    

提交回复
热议问题