如何找到两个日期之间的日期段? [英] How to find date periods between 2 dates?

查看:120
本文介绍了如何找到两个日期之间的日期段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆