如何找到两个日期之间的日期期间? [英] How to find date periods between 2 dates?
问题描述
我有 2 个日期,其中一个存储在我的日期中,对于其他日期,我使用计算列来将结束日期存储到其中,我如何计算这些日期之间的时间差,我需要日期时间在所有这些日期之间,使用 DAX 是否可行?
I have 2 dates one is stored inside my date and for other date I am using calculated column in order to store the end date into that, how an I calculate the difference in time period between those dates, I need the date period between all those dates is that possible with DAX?
如何在 DAX 中使用计算列,而且我的数据库中没有日历表.
How can I use calculated column inside my DAX and also I dont have a calender table inside my database.
2019-05-31 和结束日期是 2019-06-03 那么差异会给我 3 个日期,即 2019-05-31,2019-06-01 2019-06-02 和 2019-06-03
2019-05-31 and end date is 2019-06-03 then the difference will give me 3 dates that is 2019-05-31,2019-06-01 2019-06-02 and 2019-06-03
推荐答案
DECLARE @start_date [date] = CAST(‘2012-08-01’ as [date])
DECLARE @end_date [date] = CAST(‘2012-09-01’ as [date])
SELECT
DATEADD(day, [v].[number], @start_date)
FROM
[master].[dbo].[spt_values] [v]
WHERE
[v].[type] = ‘P’ AND
DATEADD(day, [v].[number], @start_date) <= @end_date
这篇关于如何找到两个日期之间的日期期间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!