当前位置: 代码迷 >> 综合 >> DATEDIFF
  详细解决方案

DATEDIFF

热度:38   发布时间:2024-02-26 09:03:40.0
SELECT DATEDIFF('2017-11-30', '2017-11-29') AS COL1, -- 1DATEDIFF('2017-11-30', '2017-12-15') AS col2; -- -15

https://leetcode-cn.com/problems/rising-temperature/ 

-- DATEDIFF(a.RecordDate, b.RecordDate)=1,表示a是今天b是昨天
SELECTa.id AS 'Id'
FROMWeather a JOIN Weather b ON DATEDIFF(a.RecordDate, b.RecordDate) = 1 AND a.Temperature > b.Temperature;

http://c.biancheng.net/mysql/datediff.html