You are viewing limited content. For full access, please sign in.



Add Minutes to a Date/Time field

asked on September 18

Does anyone know how I can add minutes to a date/time field to have it calculate an end date/time?  I have the Start Date/Time (#q26), which will be set by the user, and the Total Work Duration (#q186), which is calculated in minutes from the Time (minutes) for each step in the Detailed Schedule collection.  I need to calculate the End Date/Time (#q28) by taking the Start Date/Time and adding the Total Work Duration minutes to it.  Any help would be greatly appreciated as I am unable to figure out what calculation to use.

0 0


replied on September 20

Try playing with this

$(document).ready( function() {
//  let firstDate = moment().startOf('month').format().substring(0,10);
//  let lastDate = moment().endOf('month').format().substring(0,10);
  let cDate = $("#q41 input").val();
  let cTime = $("#q52 input").val();
  let cHalf = $("#q52 select").val();
  let hMoment = moment(cDate + " " + cTime + " " + cHalf, "M/D/YYYY h:mm:ss a").add(211, "minutes").format("LLL");
  let nMoment = moment().add(215, "minutes");
//  $("#q42 input").val(cDate + " " + cTime + " " + cHalf);
  $("#q42 input").val(nMoment.format());

Check out the included library

0 0
replied on September 21

Thank you James! I will play with what you provided to see if I can get it to work for me. smiley

0 0
replied on September 20

Hi Vanessa, when you enter the Milestone Time (Minutes) ie: 100 minutes + 80 Minutes + 500 Minutes = Total Work Duration = 680 minutes, when you add these minutes to Start Date, would these add on also be based on a day having only having 8 hours in it, and excluding weekends? Or would it just be the Start Date plus the number of minutes added to the starting time chosen by the user?

0 0
replied on September 21

Good question Steve!  It would be just the Start Date/Time

plus the number of minutes added to the starting time chosen by the user.  :)

0 0
replied on September 21 Show version history

When adding days or time (hours/minutes) to a date, you have to think about hours/minutes as a fraction of a day.  So if you wanted to add 90 minutes to a date, you would divide 90 mins by total number of minutes in a day (1440) and add that fraction to your date. If the number of minutes is greater than a day, the date will increment on it's own.

The formula for the End Date/Time is simply: 



If you were adding hours (such as 1.5 hours), there are 24 hours in a day, so the calculation would appear as 


0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.