Forum Discussion
Date difference between today's date and a past date - issues with M language
- Anonymous3 years ago
Hi avininpowerbi ,
Please try:if [Stage] = "Done" and [Estimated Time] > 0 and [Recorded Time] > 0 then [Estimated Time] - [Recorded Time] else if [Stage] = "To-Do" and [Due] < DateTime.Date(DateTime.LocalNow()) then Duration.TotalDays(DateTime.LocalNow() - DateTime.From([Due])) else nullBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
I used a slight varation Date.From like below :
if [Stage]="Done" and [Estimated Time]>0 and [Recorded Time]>0 then [Estimated Time]-[Recorded Time] else if [Stage]="To-Do" and [Due]< Date.From(DateTime.LocalNow() ) then Date.From((DateTime.LocalNow() ) - [Due] ) else "null"
but its hsoing me the same error as Operator=-
Left=5/25/2023 1:39:33 PM
Right=2/16/2023
and here is another one I tried ( Date.from)
if [Stage]="Done" and [Estimated Time]>0 and [Recorded Time]>0 then [Estimated Time]-[Recorded Time] else if [Stage]="To-Do" and [Due]< Date.From(DateTime.LocalNow() ) then Date.From((DateTime.LocalNow() ) - Date.From([Due]) ) else "null"
giving me this error : Operator=-
Left=5/25/2023 2:07:26 PM
Right=2/16/2023