web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adding a "0" in :01 to...
Power Apps
Answered

Adding a "0" in :01 to :09 minutes in datediff

(0) ShareShare
ReportReport
Posted on by 43

Hello everyone. 

 

I followed @ShaneYoung 's videos on datediff for calulating and created a component to allow me to transfer the text version of the datetime to SharePoint.  I need the date component since the timekeeping we do includes a night tour that rolls into the next day, and we would need to calculate the total time.

 

In creating the datediff between time and using the mod to create the hh:mm format, I ran into an issue with the minutes between :00 and :09.  Those differences would yield something like this: 12:1 or 2:9 (12 hours and 1 minute, 2 hours and 9 minutes). 

 

Question:  How can append a 0 for the minutes?

 

swong89_0-1637126446653.png

 

 

 

RoundDown(DateDiff(STDATETIME_START.'24FullDateTime',STDATETIME_END.'24FullDateTime',Minutes)/60,0) & ":" & Mod(DateDiff(STDATETIME_START.'24FullDateTime',STDATETIME_END.'24FullDateTime', Minutes),60)

 

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Hi @swong89 ,

    Assuming those are date and time fields, I just tested the below and it worked perfectly across several days

    With(
     {
     wTime:
     DateDiff(
     STDATETIME_START.'24FullDateTime',
     STDATETIME_END.'24FullDateTime',
     Minutes
     )
     },	 
     RoundDown(wTime/60,0) & 
     ":" & 
     Mod(wTime,60)
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • swong89 Profile Picture
    43 on at

    I tried your cleaned-up formula as well.  It still yielded a 1:1 instead of 1:01.

    swong89_0-1637161514278.png

     

    Yes, the fields are datetime variables, and I applied the datatimevalue around it as well to make sure it is datetime.

     

  • Verified answer
    swong89 Profile Picture
    43 on at

    @WarrenBelz I think I found the answer if do a conditional.  Let me know if this sounds correct.

     

    With(
     {
     wTime:
     DateDiff(
     STDATETIME_START.'24FullDateTime',
     STDATETIME_END.'24FullDateTime',
     Minutes
     )
     },	 
     RoundDown(wTime/60,0) & 
     ":" & 
     If(Mod(wTime,60)<10,"0" & Mod(wTime,60),Mod(wTime,60))
    )

    I applied a condition for minutes in diff less than 10 that would append the "0" to the single minutes

  • Verified answer
    WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Hi @swong89 ,

    I actually forgot about single minutes - you just need this

    With(
     {
     wTime: 
     DateDiff(
     STDATETIME_START.'24FullDateTime',
     STDATETIME_END.'24FullDateTime',
     Minutes
     )
     },
     RoundDown(
     wTime / 60,
     0
     ) & ":" & 
     Text(
     Mod(
     wTime,
     60
     ),
     "00"
     )
    )

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard