根據時間戳獲取五分鐘內的資料

2021-10-05 08:00:43 字數 1025 閱讀 9126

查詢最新五分鐘內的資料

select * from order where order_1d=

"1" and from_unixtime

(create_time/

1000

,'%y-%m-%d %h:%i:%s'

)>=

date_sub

(now()

, interval 5 minute)

#date_add 是加時間 同理date_sub是減

#select date_add

(now()

, interval 1 day)

;-當前時間加1天

#select date_add

(now()

, interval 1 hour)

;-當前時間加1小時

#select date_add

(now()

, interval 1 minute)

;-當前時間加1分鐘

#select date_add

(now()

, interval 1 second)

;-當前時間加1秒

#select date_add

(now()

, interval 1 microsecond)

;-當前時間加1毫秒

#select date_add

(now()

, interval 1 week)

;-當前時間加1周

#select date_add

(now()

, interval 1 month)

;-當前時間加1月

#select date_add

(now()

, interval 1 quarter)

;-當前時間加1季

#select date_add

(now()

, interval 1 year)

;-當前時間加1年

獲取20分鐘後(前)的時間

方式一 calendar calendar calendar.getinstance int min calendar.get calendar.minute 獲取20分鐘的時間 min 20 獲取20分鐘前的時間 min 20 calendar.set calendar.minute,min da...

mysql查詢5分鐘內的資料

查詢sql語句 select from tb log where createtime date sub now interval 5 minute 函式 描述now 返回當前的日期和時間 curdate 返回當前的日期 curtime 返回當前的時間 date 提取日期或日期 時間表示式的日期部分...

獲取某時間點前後30分鐘的時間

string astring 2020 03 02 15 31 13 建立 dateformat型別物件 yyyy mm dd hh mm ss 是正則式,分別表示年月日時分秒 dateformat df new dateformat yyyy mm dd hh mm ss 將兩個string型別的...