Mysql 查詢今天的某些時間之外的資料

2022-05-28 21:24:12 字數 727 閱讀 8632

select * from `attendancealert`

where date_format(from_unixtime(unix_timestamp(`alerttime`)),'%y-%m-%d') = date_format(now(), '%y-%m-%d') //先將日期格式轉成時間戳 然後時間戳轉成y-m-d的時間格式然後 和今天的y-m-d的時間進行對比

and date_format(from_unixtime(unix_timestamp(`alerttime`)),'%h:%i') not between '09:00' and '10:30'  //不在這個時間段

order by `alerttime` desc

//我直接把時間轉成時間型別不就可以了????

select * from

`attendancealert`

where date_format((`alerttime`),'

%y-%m-%d

')= date_format(now(), '

%y-%m-%d')

and date_format((`alerttime`),'

%h:%i

') not

between

'09:00

'and

'10:30

'order

by alerttime asc

mysql 今天 mysql查詢今天 昨天 上週

今天 select from 表名 where to days 時間欄位名 to days now 昨天select from 表名 where to days now to days 時間欄位名 1 7天select from 表名 where date sub curdate interval ...

MySQl查詢今天,昨天前固定時間的資料

今天 select from 表名 where to days 時間欄位名 to days now 昨天 select from 表名 where to days now to days 時間欄位名 1 7天前 select from 表名 where date sub curdate interv...

mysql時間查詢 MySQL按時間查詢

mysql 今天select from 表名 where to days 時間欄位名 to days now 昨天select from 表名 where to days now to days 時間欄位名 1 近7天select from 表名 where date sub curdate int...