cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kenny_McMillan
Regular Visitor

Convert seconds column into duration column hh:mm:ss.ss (needs hundredths of a second in output)

 

I am trying to convert a column that contains a time in seconds into a duration that includes hundreds of a second

 

eg

Convert 242.5 secs into  00:04:02.05

 

Regards

1 ACCEPTED SOLUTION

Hi @Kenny_McMillan,

 

Try out this formula please.

Column 2 = 
VAR hours =
    ROUNDDOWN ( [Column1] / 3600, 0 )
VAR minutes =
    ROUNDDOWN ( MOD ( [Column1], 3600 ) / 60, 0 )
VAR seconds =
    INT ( MOD ( [Column1], 60 ) )
VAR milliseconds =
    round(MOD ( [Column1], 1 ) * 100,0)
RETURN
    FORMAT(hours,"00") & ":"
        & FORMAT(minutes, "00")
        & ":"
        & FORMAT(seconds, "00")
        & "."
        & FORMAT(milliseconds, "00")

dd

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-jiascu-msft
Microsoft
Microsoft

Hi @Kenny_McMillan,

 

Seems there isn't a built-in support of such format. Please vote up this idea here. The workaround could be as below.

Column 2 =
VAR hours =
    ROUNDDOWN ( [Column1] / 3600, 0 )
VAR minutes =
    ROUNDDOWN ( MOD ( [Column1], 3600 ) / 60, 0 )
VAR seconds =
    INT ( MOD ( [Column1], 60 ) )
VAR milliseconds =
    ROUND ( MOD ( [Column1], 1 ) * 100, 0 )
RETURN
    hours & ":"
        & minutes
        & ":"
        & seconds
        & "."
        & milliseconds

miniseconds

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Dale for the help, 

 

How would you force each number to be of two digits length ?  4 minutes 2.17 secs would be 00:04:02.17

 

Regards

Hi @Kenny_McMillan,

 

Try out this formula please.

Column 2 = 
VAR hours =
    ROUNDDOWN ( [Column1] / 3600, 0 )
VAR minutes =
    ROUNDDOWN ( MOD ( [Column1], 3600 ) / 60, 0 )
VAR seconds =
    INT ( MOD ( [Column1], 60 ) )
VAR milliseconds =
    round(MOD ( [Column1], 1 ) * 100,0)
RETURN
    FORMAT(hours,"00") & ":"
        & FORMAT(minutes, "00")
        & ":"
        & FORMAT(seconds, "00")
        & "."
        & FORMAT(milliseconds, "00")

dd

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much Dale this is great.  I assume there is no way that this can be forced into a Duration format though ?

Hi @Kenny_McMillan,

 

There is a Duration type for the Power Query while there isn't a Duration type for DAX. That's why I suggested you vote up the idea.

Convert_seconds_column_into_duration_column

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you dale

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors