閒來自己寫的一個日期與秒數的轉換
/**
*第一個空白輸入你想轉換的日期,沒輸入則為今天凌晨
*第二個空白輸入你想加的天數,沒輸入則為0 極限值 9523.1345312499
*第三個空白輸入你想減的天數,沒輸入則為0 極限值 15332.00028
*/
SELECT
t1.todate AS '轉換前日期',
t1.tosecond AS '轉換前秒數',
t1.toadd AS '欲加的天數',
(t1.tosecond+3600*24*t1.toadd) AS '加後的秒數',
FROM_UNIXTIME(t1.tosecond+3600*24*t1.toadd) AS '加後的日期',
t1.toreduce AS '欲減的天數',
(t1.tosecond-3600*24*t1.toreduce) AS '減後的秒數',
FROM_UNIXTIME(t1.tosecond-3600*24*t1.toreduce) AS '減後的日期'
FROM
(SELECT
mydate.todate AS todate,
UNIX_TIMESTAMP(mydate.todate) AS tosecond,
myadd.toadd AS toadd,
myreduce.toreduce AS toreduce
FROM
(SELECT IFNULL(?, curdate()) AS todate) AS mydate,
(SELECT IFNULL(?, 0) AS toadd) AS myadd,
(SELECT IFNULL(?, 0) AS toreduce) AS myreduce
)
AS t1
其它文章
沒有留言:
張貼留言