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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.