Duration format change

ursua

New Member
Joined
Jan 9, 2020
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi,
So i have a column [Custom] which is a result of subtraction between a column with start date and end date in format like that 1,2345 etc. i want to change it to duration but only in format HH:MM:SS, not DD.HH:MM:SS. I tried to add a new column using Custom Column function like that: = FORMAT(Table1[Custom],"hh:mm:ss"), but it didn't work (Power BI says that it can't recognize 'FORMAT'.
Any ideas how to get desired format?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Well, your going to have to do the math to calculate the difference
=HOUR(H31-G31)+((DAYS(H31,G31)-1)*24)&":"&MINUTE(H31-G31)&":"&SECOND(H31-G31)
Where H31 is the end date/time and G31 is the beginning date/time
 
Upvote 0
Hi,
Unfortunately doesn't work for me because "The expression "HOUR" wasn't recognized." :(
 
Upvote 0
is that what you want?
SDTEDTDurationDurationTime
20/05/2020 10:5522/05/2020 09:101.22:14:3046:14:30

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"SDT", type datetime}, {"EDT", type datetime}}),
    Duration = Table.AddColumn(Type, "Duration", each [EDT] - [SDT], type duration),
    DurationTime = Table.AddColumn(Duration, "DurationTime", each Text.From(Duration.Days([Duration]) * 24 + Duration.Hours([Duration]))&":"&Text.From(Duration.Minutes([Duration]))&":"&Text.From(Duration.Seconds([Duration])))
in
    DurationTime
 
Upvote 0
or even like this
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"SDT", type datetime}, {"EDT", type datetime}}),
    DurationTime = Table.AddColumn(Type, "DurationTime", each Text.From(Duration.Days([EDT] - [SDT]) * 24 + Duration.Hours([EDT] - [SDT]))&":"&Text.From(Duration.Minutes([EDT] - [SDT]))&":"&Text.From(Duration.Seconds([EDT] - [SDT])))
in
    DurationTime
 
Upvote 0
or in case time is eg. 05:02:07
SDTEDTDurationTime
20/05/2020 10:5522/05/2020 09:1046:14:30
20/05/2020 00:0122/05/2020 01:0349:01:30
20/05/2020 05:0722/05/2020 08:0550:58:00
20/05/2020 00:0122/05/2020 00:0047:59:00

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"SDT", type datetime}, {"EDT", type datetime}}),
    DurationTime = Table.AddColumn(Type, "DurationTime", each Text.PadStart(Text.From(Duration.Days([EDT] - [SDT]) * 24 + Duration.Hours([EDT] - [SDT])), 2, "0")&":"&Text.PadStart(Text.From(Duration.Minutes([EDT] - [SDT])), 2, "0")&":"&Text.PadStart(Text.From(Duration.Seconds([EDT] - [SDT])), 2, "0"))
in
    DurationTime
 
Upvote 0

Forum statistics

Threads
1,223,786
Messages
6,174,547
Members
452,571
Latest member
MarExcelTips

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top