Forum Discussion
MisterT
10 years agoRegular Visitor
Custom Column, DATEDIFF, TODAY....nothing works?
So this is driving me a bit crazy. Something that should be so simple is taking so long to solve and none of the forum suggestions I've seen work. And I know I can solve this by adding columns i...
- 10 years ago
You can try the below exprssion in DAX but not in Power Query.
elapsedDays = DATEDIFF( [EmailDate],TODAY() , DAY)
And I know I can solve this by adding columns into the underlying database (or adding views) but I don't want to do that and it kind of defeats the purpose of a BI tool surely.
Or even directly in the query, no need to add columns to the underlying table.
select emaildate,datediff(day,emaildate,getdate()) elapsedDays from testdb.dbo.tableDate
Afernandez
8 years agoNew Member
I was facing the same issue and for me the best solution has been to calculate directly the substract of the two DateColumns with the Custom Column ( = DateB - DateA ).
It returns a column with the time difference. After that it is easy to transform to days, months or any other date type.
Example:
Date A =02/01/2018 18:15:21
Date B = 08/01/2018 6:35:46
Returned Value = 5.12:20:25.0133334