Forum Discussion
How to subtract hours from DateTime data using DAX?
- 9 years ago
Try this in DAX:
MaxDateFiveHourDiff = MAX(Table1[DateTime]) - 5/24
Power Pivot (and Excel) store stores dates and times as a number representing the number of days since 1900-Jan-0, plus a fractional portion of a 24 hour day: ddddd.tttttt . This is called a serial date, or serial date-time. Value to the left of the decimal point are days. The value to the right of the decimal point are a decimal representation of the 24 hour clock.
So in your case you can simple subtract 5 / 24 = .2083 from the date-timestamp to subtract 5 hours.
new column = table[Date-timestamp] - .2083
If you wanted to subtract 5 hours and 15 minutes from the date-timestamp you would subtract 5.25 / 24 = .2187. If you needed to subtract 4 hours and 8 minutes, you would subtract 8 / 60 = .133 and therefore 4.133 / 24 = .17222. And so on...
Not sure if this is the best way, but what comes to mind for me.
- kaka9 years agoHelper II
Thanks for ths info.