Hours Spent

907
8
Jump to solution
03-27-2023 11:11 AM
aprhyde11
New Contributor III

I'm trying to display the total hours spent on a project per day per team. I'm new to arcade so everything I've found hasn't quite worked for what I need. 

The only time carrying attribute that I have is the date with time. From my research I've been finding that I need a separate time attribute? 

Is there anyway that I can show this data? 

If you need more info please let me know

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

To show a duration, you need a start and end time, which you'd be able to feed into the DateDiff function to get the hours.

DateDiff($datapoint['end_time'], $datapoint['start_time'], 'hours')
- Josh Carlson
Kendall County GIS

View solution in original post

8 Replies
jcarlson
MVP Esteemed Contributor

To show a duration, you need a start and end time, which you'd be able to feed into the DateDiff function to get the hours.

DateDiff($datapoint['end_time'], $datapoint['start_time'], 'hours')
- Josh Carlson
Kendall County GIS
aprhyde11
New Contributor III

I have added start and end times but still can't seem to get the difference to display. Do you have any more suggestions?

0 Kudos
jcarlson
MVP Esteemed Contributor

What does your expression look like? Hard to say why it's not displaying without seeing what's actually happening.

- Josh Carlson
Kendall County GIS
0 Kudos
aprhyde11
New Contributor III
This is what it looks like. I'm trying to create an Indicator on a dashboard. The indicator says "Unable to execute Arcade script"
 
var startDate = Date($datapoint.timestart);
var endDate = Date($datapoint.timeend);
var age = DateDiff(endDate, startDate, 'hours');

return {
  //textColor:'',
  //backgroundColor:'',
  //topText: '',
  //topTextColor: '',
  //topTextOutlineColor: '',
  //topTextMaxSize: 'medium',
  middleText: age,
  middleTextColor: '',
  middleTextOutlineColor: '',
  middleTextMaxSize: 'large',
  //bottomText: '',
  //bottomTextColor: '',
  //bottomTextOutlineColor: '',
  //bottomTextMaxSize: 'medium',
  //iconName:'',
  //iconAlign:'left',
  //iconColor:'',
  //iconOutlineColor:'',
  //noValue:false,
  //attributes: {
    // attribute1: '',
    // attribute2: ''
  // }
}
 
0 Kudos
jcarlson
MVP Esteemed Contributor

Are your fields actually dates? If so, you don't need to use the Date function.

jcarlson_0-1680034273035.png

PS - You may want to use Round or Text to format the output nicely.

- Josh Carlson
Kendall County GIS
0 Kudos
aprhyde11
New Contributor III

Yes the time fields include the date and time. I'm using the start and end functions built in to survey123. 

Unfortunately, it still isn't working for me  😭

Thank you so much for your help though!

0 Kudos
jcarlson
MVP Esteemed Contributor

Can you just confirm that it's a true DateTime field, and not text? I've had surveys store other datatypes as text in the past.

- Josh Carlson
Kendall County GIS
0 Kudos
aprhyde11
New Contributor III

It is by date

aprhyde11_0-1680037024836.png

 

0 Kudos