Select to view content in your preferred language

Update integer field with DateDiff

404
1
Jump to solution
02-28-2024 06:27 AM
MikhaylaB
Frequent Contributor

I've been asked to create an Arcade script that calculates the difference between the start and end date of a project. The value should populate an integer field with hours. The start and end date fields are formatted with date and time, because we need to track to the hour how long is spent working on the project. 

I have the below script and fields. I would like to implement this as an attribute rule going forward. Any idea how to get it to automatically populate the TimeDiff field? I'm assuming the inclusion of time is the issue, but I need to include it. 

 

MikhaylaB_1-1709130393846.png

 

MikhaylaB_0-1709130369476.png

 

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
MikhaylaB
Frequent Contributor

This works:

var StartDate = $feature.TimeStart
var EndDate = $feature.TimeEnd
var TimeDiff = DateDiff(EndDate, StartDate, 'hours')
return TimeDiff

View solution in original post

0 Kudos
1 Reply
MikhaylaB
Frequent Contributor

This works:

var StartDate = $feature.TimeStart
var EndDate = $feature.TimeEnd
var TimeDiff = DateDiff(EndDate, StartDate, 'hours')
return TimeDiff

0 Kudos