Announcement

Collapse
No announcement yet.

Calculate the number of minutes.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #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


    • #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


      • #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


        • #5

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

          Comment


          • #6
            In my examples I used this:

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

            Comment


            • #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


              • #8
                Thank you,

                Comment

                Working...
                X