Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
reacharihant
Regular Visitor

Converting seconds into day hours min sec

I need to convert seconds into day hours min sec. How can I do it? 

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

Preferably in Power Query. e.g.: 

 

let
    Source = #table(type table[Seconds = Int64.Type],{{4000},{40000},{100000},{1000000}}),
    Day    = Table.AddColumn(Source, "Day",   each            Number.IntegerDivide([Seconds],24*60*60),  Int64.Type),
    Hours  = Table.AddColumn(Day,    "Hours", each Number.Mod(Number.IntegerDivide([Seconds],60*60),24), Int64.Type),
    Min    = Table.AddColumn(Hours,  "Min",   each Number.Mod(Number.IntegerDivide([Seconds],60),60),    Int64.Type),
    Sec    = Table.AddColumn(Min,    "Sec",   each Number.Mod([Seconds],60),                             Int64.Type)
in
    Sec

 

or otherwise in DAX:

 

DAXDay   =     INT(Query1[Seconds]/(24*60*60))
DAXHours = MOD(INT(Query1[Seconds]/(60*60)),24)
DAXMin   = MOD(INT(Query1[Seconds]/60),60)
DAXSec   = MOD(    Query1[Seconds],60)

 

Specializing in Power Query Formula Language (M)

View solution in original post

2 REPLIES 2
MarcelBeug
Community Champion
Community Champion

Preferably in Power Query. e.g.: 

 

let
    Source = #table(type table[Seconds = Int64.Type],{{4000},{40000},{100000},{1000000}}),
    Day    = Table.AddColumn(Source, "Day",   each            Number.IntegerDivide([Seconds],24*60*60),  Int64.Type),
    Hours  = Table.AddColumn(Day,    "Hours", each Number.Mod(Number.IntegerDivide([Seconds],60*60),24), Int64.Type),
    Min    = Table.AddColumn(Hours,  "Min",   each Number.Mod(Number.IntegerDivide([Seconds],60),60),    Int64.Type),
    Sec    = Table.AddColumn(Min,    "Sec",   each Number.Mod([Seconds],60),                             Int64.Type)
in
    Sec

 

or otherwise in DAX:

 

DAXDay   =     INT(Query1[Seconds]/(24*60*60))
DAXHours = MOD(INT(Query1[Seconds]/(60*60)),24)
DAXMin   = MOD(INT(Query1[Seconds]/60),60)
DAXSec   = MOD(    Query1[Seconds],60)

 

Specializing in Power Query Formula Language (M)

Thanks! Got it.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors