Count days in date range?

我的梦境 提交于 2019-12-02 01:22:15

Not really clear if you are looking for

DATEDIFF('2010-03-31', '2010-01-01')

or

COUNT(DISTINCT daily_individual_racking_date)

What exactly are you trying to count? The total number of distinct values of daily_individual_tracking_date? Do you need it in the same query as the count(*) query?

You can use the MySQL datediff function:

SELECT DATEDIFF('2010-01-01','2010-01-31') AS DiffDays

It should return a floating point, where 1.0 represents a single day.

This depends on what SQL server you're using.

If you're using MS-SQL Server, you can use the function DateDiff

Michaelkay

I'm not sure which SQL you are using. TSQL has a DATEDIFF that will count the number of days between two dates. See this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!