Forum Discussion
Calculate Duration from date time fields
- 4 years ago
Hi, yaman123
You can try the following methods.
1. First convert all intervals to seconds.
Seconds = DATEDIFF ( [Start time], [End time], SECOND )2. Then convert the seconds to hour-minute-second format.
Duration = INT ( [Seconds] / 3600 ) & ":" & INT ( ( [Seconds] - INT ( [Seconds] / 3600 ) * 3600 ) / 60 ) & ":" & [Seconds] - INT ( ( [Seconds] - INT ( [Seconds] / 3600 ) * 3600 ) / 60 ) * 60 - INT ( [Seconds] / 3600 ) * 3600Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, yaman123
You can try the following methods.
1. First convert all intervals to seconds.
Seconds =
DATEDIFF ( [Start time], [End time], SECOND )
2. Then convert the seconds to hour-minute-second format.
Duration =
INT ( [Seconds] / 3600 ) & ":"
& INT ( ( [Seconds] - INT ( [Seconds] / 3600 ) * 3600 ) / 60 ) & ":"
& [Seconds]
- INT ( ( [Seconds] - INT ( [Seconds] / 3600 ) * 3600 ) / 60 ) * 60
- INT ( [Seconds] / 3600 ) * 3600
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- jtetz302 years agoRegular Visitor
In excel, all I need to do is subract the end date/time from the start date/time and format as [h]:mm to get hours and minutes. This code is how I have to do that calculation is LESS sophisticated applications, which is annoying. WHY would the mature calculation be removed from the newer tool set?
- jtetz302 years agoRegular Visitor
Also, this will yield a string so I cannot math it further... Is this really the only answer
- yaman1234 years agoPost Partisan
Thanks, that does give me the reuslts I want but can it be formatted to Time so I can take the Average Time?
- v-zhangti4 years agoCommunity Support
Hi, yaman123
Power BI does not allow converting more than 24 hours to time. Maybe you can get the average from seconds and convert to time format.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.