Calculate the number of minutes.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abidoss
    Senior Member
    • Mar 2023
    • 230

    Calculate the number of minutes.

    Hello friends, is there a way to calculate the number of minutes and hours between two dates and display it in a field?


    For example, in the capture, the number of minutes is: 03 min.
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1608

    #2
    yes possible with datetime Diff

    minutes = datetime\diff(end, start, 'minutes');

    where end is in your case 10:10 and start 10:07

    I use this formula to calculate the time I need for a task. I put in start and end time and the minutes are calculated. In another field I convert the minutes to hours (float) and multiply with my hour rate to calculate the fee, my client has to pay for my work.
    Furthermore I reversed the calculation, e.g. I put in the start time and the minutes, from which then the end time is calculated. I did that for fun, because it is possible.

    Comment

    • abidoss
      Senior Member
      • Mar 2023
      • 230

      #3
      Thank you, it works well for me too. However, if the time is more than 60 minutes, for example, 75 minutes, how do we display 1h15min?

      Comment

      • ThomasB
        Senior Member
        • Mar 2022
        • 163

        #4
        I'm using this formular to calculate the duration of an incident. Start and end time the incident.

        Code:
        $totalMinutes = datetime\diff(incidentEndtime, incidentstarttime, 'minutes');
        $hours = number\format(number\floor(($totalMinutes / 60), 0));
        $minutes = number\format(number\floor(($totalMinutes - ($hours * 60)), 0));
        
        impactDuration = string\concatenate($hours,' Hours ', $minutes, ' Minutes');​​

        Comment

        • abidoss
          Senior Member
          • Mar 2023
          • 230

          #5

          So, the "impactDuration" field is a text field, not a float.​

          Comment

          • ThomasB
            Senior Member
            • Mar 2022
            • 163

            #6
            In my examples I used this:

            Code:
            impactDuration     Duration          Varchar
            incidentstarttime  Start of impact   Date-Time​​
            incidentEndtime    End of impact     Date-Time

            Comment

            • BigBoss
              Member
              • Nov 2023
              • 86

              #7
              You can also add the days if necessary

              $totalMinutes = datetime\diff(dateFin, dateStart, 'minutes');
              $days = number\format(number\floor(($totalMinutes / (24 * 60)), 0));
              $remainingMinutes = $totalMinutes - ($days * 24 * 60);
              $hours = number\format(number\floor(($remainingMinutes / 60), 0));
              $minutes = number\format(number\floor(($remainingMinutes - ($hours * 60)), 0));

              Duration = string\concatenate($days, ' Days ', $hours, ' Hours ', $minutes, ' Minutes');

              Comment

              • abidoss
                Senior Member
                • Mar 2023
                • 230

                #8
                Thank you,

                Comment

                • Ashif Malayil
                  Senior Member
                  • Dec 2023
                  • 176

                  #9
                  Is there any formula to find last 24 hours from Created At date and time?

                  Comment

                Working...