1
我嘗試從日數中獲取年,月,日的數量。我嘗試這樣做:如何將日期轉換爲年,月,日日期格式
SELECT enddate,startdate,extract(month from enddate)-extract(month from startdate)
FROM workexpdeails ;
我嘗試從日數中獲取年,月,日的數量。我嘗試這樣做:如何將日期轉換爲年,月,日日期格式
SELECT enddate,startdate,extract(month from enddate)-extract(month from startdate)
FROM workexpdeails ;
SELECT
enddate
,startdate
,(YEAR(enddate)*12+MONTH(enddate)) - (YEAR(startdate)*12+MONTH(startdate))
as diffmonths
,DATEDIFF(enddate, startdate) as diffdays
FROM workexpdeails ;
參見:http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
你有什麼用 「的年月日數」 呢? – 2011-12-22 11:09:55