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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Change time format from hh:mm:s to hh:mm:ss

Hello,

 

I would like to change the time format from hh:mm:s to hh:mm:ss.

 

I used the following  measure:

PCR =
Var vSeconds = 'Medidas'[Average]
var vMinutes = int(vSeconds/60)
var vRemainingSeconds= int(MOD(vSeconds,60))
var vHours = INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
return
vHours&
vRemainingMinutes&":"&
vRemainingSeconds
 
The output is: 
claud2022_0-1643714041737.png

 

But I would like to see the 0 before the number when the seconds don't reach 10. Something like this:

03:14

03:16

03:04

03:08

 

claud2022_1-1643714682192.png

 

What measure should I use to get it?

 

Thanks in advance for your help!

 

 

2 ACCEPTED SOLUTIONS
Samarth_18
Community Champion
Community Champion

HI @Anonymous ,

You can update your code like this:-

PCR =
VAR vSeconds = 'Medidas'[Average]
VAR vMinutes =
    INT ( vSeconds / 60 )
VAR vRemainingSeconds =
    INT ( MOD ( vSeconds, 60 ) )
VAR vHours =
    INT ( vMinutes / 60 )
VAR vRemainingMinutes =
    MOD ( vMinutes, 60 )
RETURN
    vHours & vRemainingMinutes & ":"
        & IF ( vRemainingSeconds < 9, "0" & vRemainingSeconds, vRemainingSeconds )

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

Anonymous
Not applicable

I  updated it and it's working

Thanks a lot !! @Samarth_18 

 

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

HI @Anonymous ,

You can update your code like this:-

PCR =
VAR vSeconds = 'Medidas'[Average]
VAR vMinutes =
    INT ( vSeconds / 60 )
VAR vRemainingSeconds =
    INT ( MOD ( vSeconds, 60 ) )
VAR vHours =
    INT ( vMinutes / 60 )
VAR vRemainingMinutes =
    MOD ( vMinutes, 60 )
RETURN
    vHours & vRemainingMinutes & ":"
        & IF ( vRemainingSeconds < 9, "0" & vRemainingSeconds, vRemainingSeconds )

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

I  updated it and it's working

Thanks a lot !! @Samarth_18 

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.