Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to change "Decimal Number" into Time (mm:ss)

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I am using decimal number field to enter the time in minutes:seconds. At the end we need to calculate total Duration. Below is the screenshot.

How to change the Total Duration to Time( ex: If it is 6.70 change it to 7.10(7minutes 10 seconds) )

2017_2D00_08_2D00_16_5F00_105558.png

*This post is locked for comments

  • ram r Profile Picture
    ram r on at
    RE: How to change "Decimal Number" into Time (mm:ss)

    I would prefer a duration field(whole number) and if that's not an option, then with the current design,

    1. Add a javascript validation so that the decimals never exceed .59

    2. Convert each and every field to seconds, add them together and then get minutes out of the sum

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,477 on at
    RE: How to change "Decimal Number" into Time (mm:ss)

    It's not even correct to convert the total:

    1.50 + 1.50 + 1.50 will render 4:50. You can't make it 5:30 no matter how you try (but that's what it is when you add minutes:seconds rather than decimals)

    You'll likely need some javascript to do the calculations, and, then, to convert the resutls (or change the fields as Henry suggested).First, might convert every decimal to seconds (minutes * 60 + seconds), then add up all of them, then convert the result to "decimal time":

    result = floor(result / 60) + (result - floor(result / 60)*60)/100;

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to change "Decimal Number" into Time (mm:ss)

    If you can't convert the field to duration (per Henry's suggestion), you can use the following logic to get the number format:

    sciencing.com/convert-decimal-hours-minutes-6178981.html

    Not sure if there is a JavaScript function to do this, but, you can create a function that does the following:

    1. Split the number that you have on the period, which will give you number1 = 6, number2 = 70

    2. Check if values number2 is greater than 60. If yes Add 1 to number 1, and subtract 60 from number2 to get number 3. You can use mod function here (%)

    3. There you have it: Number1 has 7, Number3 has 10. Combine them and get the result.

    If you need to get that into time variable you can use the JavaScript Date function, but not sure if that is what you are looking for.

    Not the most elegant way, but might be useful. Possibly there are JS functions, but not aware of this scenario.

  • Suggested answer
    Henry J. Profile Picture
    Henry J. 5,237 on at
    RE: How to change "Decimal Number" into Time (mm:ss)

    I suggest you recreate your fields. Change your attribute type to "Whole Number" and type "Duration".

    That way CRM interprets them like you desire, and you can also use Calculated Fields to to the math.

    These kinds of fields store a number of seconds  n the database but they display something user friendly (1 hour, etc.)

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans