Post

2 followers Follow
0
Avatar

Get duration in an hours

Hi!
Could you help me?
I want to get report on Duration for specific user and I want to get duration amount in an hours (because it's saved in an hours), I use API call /V2.0/services/data/aggregateQuery with body:
{
"typeName": "Timesheet",
"aggregations": [

{
"function": "Sum",
"fieldName": "duration",
"alias": "duration"
}
],
"where": {
"and": [
{
"leftExpression": {"fieldName": "reportedDate"},
"operator": "GreaterThanOrEqual",
"rightExpression": {"value": "2018-12-01"}
},
{
"leftExpression": {"fieldName": "reportedDate"},
"operator": "LessThanOrEqual",
"rightExpression": {"value": "2018-12-31"}
}, 
{
"leftExpression": {"fieldName": "reportedby"},
"operator": "Equal",
"rightExpression": {"value": "/User/12fmbcm1kfbt45s25z7bxvego617"}
}
]


but in the response I get the sum in the days. For example, user tracked 40.5 h for month, in the response I get 5.0625. How can I get the sum in an hours using this api call?

Bvy Vetal Answered

Please sign in to leave a comment.

1 comment

0
Avatar

Hello Bvy,

I'm not sure if there's a way to output the sum in hours.

My recommendation is to simply multiply the result by 8. If that is not a satisfactory solution, an alternative way would be to create a custom numeric formula field on the Timesheet entity that expresses Duration as number of hours and then using that in your API call: 

Please let me know if this is helpful.

Thank you!

Roland Pumputis 0 votes