I want to Calculate Timespent automatically, Is there a way to do this without any code
Hi I am not a developer, I want to Calculate Timespent automatically, Is there a way to do this without any code. For a project management, our deliverables have timesheets. I want to calculate time spent with the help of start date and end date & time field. Is there a way to calculate this ?
-
Hi Jayraj,
yes, there is a way. But you have to create a calculation field for that and to write (or at least copy) some simple Javascript code. How this code looks like, depends on your setup. Are the time sheets connected via a relationship field to Deliverables? Would like to calculate spent time in Timesheets only or do you want to sum all time spnet for one Deliverable in the Deliverables App? Btw: You can't calculate the time spent if start and end date are in the same date field, you need two date fields for that, one for start and one for end.
Would be helpful If you could share some more details of your app setup and your needs.
Rainer
rg@delos-consulting.com -
Hi Rainer,
Yes the Start Date and End Date are two different fields with time
Based on the state date time and the end date time I want to calculate how long it took to complete the deliverable which should give me the duration
Even if its in the deliverables app it is fine, as then I can shoot that calculation into the timesheet app for further calculation.
Can you guide me here please.
Regards,
Jayraj -
Hello Jayraj,
you can calculate the time spent in the time Timesheet app and then sum the duration of all timesheets for a deliverable in the deliverables app. Create a calculation field in the Timesheet App and call it eg. "TimeSpent":
var start = moment(@startDate); var end = moment(@endDate); var unit = "days"; end.diff(start, unit)
You can change the unit as you like it: e.g. to "hours" or "minutes". That counts calender days. If you want workdays only , you'll find a solution here, where I've posted a code for calculating the duration in business days https://help.podio.com/hc/communities/public/questions/202828487-Calculating-workdays?locale=en-us
You can copy it, only ypur date field names into the variables at the beginning.For summing all Time spent entries for one deliverable create a calculation field in the Deliverables app with:
@sum of TimeSpent
For that the Time spent app must be related to the deliverables app via a relationship field (I assume that you already have that relationship field in the Timesheet app).
Rainer
-
Hi Jayraj
that IS the exact JavaScript Code. You only have to put in the field names of YOUR date fields (type @fieldname and select the token from the list which opens after typing @ The more you type the shorter the list becomes) and than in the calc field in Deliverables after @sum of the fieldname of the calc field in Time Spent which calculates the duration. The code for calculating workdays you can also copy and paste as it is (only put in your date field names), The text behind // are only comments, you can take altogether into your calculation field.
Rainer
rg@delos-consulting.com -
NB: The result of this calculation is an integer. That means for your example
My Start Date is 14/04/2015 4:00 PM
My End Date is 14/04/2015 7:00 PM- in case of using "Days" as unit result = 0 (exact result is 0.13 days)
- in case of using "hours" as unit result = 3 (exact result = 3.00 hours)
But if end date is 7:30 you also will get the result 3 (hours; exact result would 3.5 hours).
So if you want the exact result with decimals take a the next smaller unit and devide it like
var unit = "minutes"
end.diff(start,unit)/60 // result = 3,5 hours (for end date 7:30 PM)
or
var unit = "hours"
end.diff(start, unit)/24 // result = 0.13 daysRainer
Please sign in to leave a comment.
Comments
11 comments