用SQL查询查找日期之间的区别

时间:2021-07-28 13:26:19

I need a sql query which will find the difference between two dates . I have already tried the between clause query but It include the Starting date . But I need a query that exclude the start date . and so please provide me a different one.

我需要一个SQL查询,它将找到两个日期之间的差异。我已经尝试过了子句查询,但它包含了开始日期。但我需要一个排除开始日期的查询。所以请给我一个不同的。

1 个解决方案

#1


1  

You can use the DATEDIFF method

您可以使用DATEDIFF方法

E.g:

SELECT DATEDIFF(SELECT DATE_ADD(start_date,INTERVAL 1 DAY),end_date);

If you want to exclude the start_date, or change the interval as per your requirements

如果要排除start_date,或根据您的要求更改间隔

#1


1  

You can use the DATEDIFF method

您可以使用DATEDIFF方法

E.g:

SELECT DATEDIFF(SELECT DATE_ADD(start_date,INTERVAL 1 DAY),end_date);

If you want to exclude the start_date, or change the interval as per your requirements

如果要排除start_date,或根据您的要求更改间隔