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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
joshua1990
Post Prodigy
Post Prodigy

HHMMSS without leading Zeros to HH:MM:SS

Hi all!

I have a column that shows me the time of the day but without leading zeros:

For instance:

  • Instead of 00:00:02 it is 2
  • Instead of 02:00:30 it is 20030

 

How can I change this within power query?

 

Thanks in advance

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @joshua1990 ,

 

Add a new custom column like this:

let _time = Text.PadStart(Text.From([time]), 6, "0") in
Text.Combine(
    {
        Text.Start(_time, 2),
        Text.Middle(_time, 2, 2),
        Text.End(_time, 2)
    }, ":"
)

 

Working example query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlKK1QGSBgbGBmCWsamZAYRlaWRuaghmGRoamRqbKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [time = _t]),
    chgToInteger = Table.TransformColumnTypes(Source,{{"time", Int64.Type}}),
    addTimeFormatted = Table.AddColumn(chgToInteger, "timeFormatted", each
    let
        _time = Text.PadStart(Text.From([time]), 6, "0")
    in
        Text.Combine(
            {
                Text.Start(_time, 2),
                Text.Middle(_time, 2, 2),
                Text.End(_time, 2)
            }, ":"
        )
    )
in
    addTimeFormatted

 

Example output:

BA_Pete_0-1673868978494.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @joshua1990 ,

 

Add a new custom column like this:

let _time = Text.PadStart(Text.From([time]), 6, "0") in
Text.Combine(
    {
        Text.Start(_time, 2),
        Text.Middle(_time, 2, 2),
        Text.End(_time, 2)
    }, ":"
)

 

Working example query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlKK1QGSBgbGBmCWsamZAYRlaWRuaghmGRoamRqbKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [time = _t]),
    chgToInteger = Table.TransformColumnTypes(Source,{{"time", Int64.Type}}),
    addTimeFormatted = Table.AddColumn(chgToInteger, "timeFormatted", each
    let
        _time = Text.PadStart(Text.From([time]), 6, "0")
    in
        Text.Combine(
            {
                Text.Start(_time, 2),
                Text.Middle(_time, 2, 2),
                Text.End(_time, 2)
            }, ":"
        )
    )
in
    addTimeFormatted

 

Example output:

BA_Pete_0-1673868978494.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.