[英]Calculating time difference between two dates
I have data similar to the following:我有类似于以下的数据:
`date1` `date2`
2013-04-02 NULL
2013-03-26 NULL
2013-03-26 2013-03-06
2013-03-25 2013-03-05
I would like to find the difference in days.我想找出天数的差异。 For example:例如:
`date1` `date2` `difference`
2013-04-02 NULL NULL
2013-03-26 NULL NULL
2013-03-26 2013-03-27 1.0 # DAYS
2013-03-25 2013-03-28 3.0
How would I calculate this difference?我将如何计算这种差异?
You can use a DATEDIFF function.您可以使用 DATEDIFF 函数。
DATEDIFF(date1,date2)
The following SELECT statement:以下 SELECT 语句:
SELECT DATEDIFF('2014-11-30','2014-11-29') AS DiffDate
Output will be.输出将。
DiffDate
1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.