I have an incident date and time field spanning across several years, but i'm wanting to only show the incidents by a 24 hours period in the timeline widget. I'm not interested in the date aspect, I want to see all points of incidents within 15 minute intervals throughout the day, Midnight - 12:15am, 12:15-12:30 etc etc
I couldn't see an easy way to do this within the experience builder, so i thought a way around it could be to create another date and time field, which has the same date, but the time is taken from my incident date/time field. Does anyone know a field calculate expression to help with this? or know of any easier way to show just the time within the timeline widget please?
Any help would be much appreciated
I'm not sure the widget can just take a time, you may need to extract the Hour and Minute and add it to an arbitrary date, then use the time slider as normal (with 15 minute display window).
So field calculate your records and make them occur on all the same day (1 Jan 2023):
//example, replace with your date field var yourDate = Date('2023-03-01 10:36:00') //change to any arbitrary date you want //e.g. $feature.date var arbitrary = Date('2023-01-01 00:00:00') //calculate number of minutes from midnight var minutes = Hour(yourDate) * 60 + Minute(yourDate) //add minutes to arbitrary date (e.g. 1 Jan 2023) var result = DateAdd(arbitrary, minutes, 'minutes') return result
Another option is to not use the widget, and just display your times by grouped symbology per time interval. There' s an excellent blog here - https://www.esri.com/arcgis-blog/products/mapping/mapping/unwinding-the-clock-visualizing-time-with-...
This section from the blog details how to group by hour of the day:
At what time of day was the incident reported (morning, afternoon, evening)?
var t = Hour($feature.Created_Date); When( t >= 22 || t < 6, "Night", t >= 6 && t < 11, "Morning", t >= 11 && t < 13, "Midday", t >= 13 && t < 17, "Afternoon", t >= 17 && t < 22, "Evening", "Invalid date" );
Your code might look something like this: (There's obviously going to be a better function to create this but it might help you for the moment)
//replace example datetime with $feature.youorDateColumn var now = Date('2022-01-01 10:34:00') //get minutes from midnight var m = Hour(now) * 60 + Minute(now) When( t >= 0 || t < 15, "Midnight - 12:15am", t >= 15 && t < 30, "12:15am - 12:30am", t >= 30 && t < 45, "12:30am - 12:45am", t >= 45 && t < 60, "12:45am - 1:00am", t >= 60 && t < 75, "1:00am - 1:15am and so on...", "Invalid date" );
Thank you so much for your help here. I don't think i can not use the widget, as i have various layer views for it, e.g. heat maps and clusters
I'm new with arcade so apologies for getting confused. I already have the incident date and time field in a 24 hour clock format. I have opened the layer up in ArcGIS Pro and using field calculate with the following expression. The incident date/ time field is called Incident_Time_Date
//example, replace with your date field
var yourDate = Date($feature.Incident_Time_Date)
//change to any arbitrary date you want
var arbitrary = Date('2023-01-01 00:00:00')
//calculate number of minutes from midnight
var minutes = Hour(yourDate) * 60 + Minute(yourDate)
//add minutes to arbitrary date (e.g. 1 Jan 2023)
var result = DateAdd(arbitrary, minutes, 'minutes')
Some have worked perfectly and exactly what i'm after, e.g. the time 19:28:46 (hh:mm:ss) is now 19:28:00, but some have added an hour, e.g. 09:20:44 has turned to 10:20:00, as well as 12:26:59 has changed to 13:26:00. Another one that was 12:51:00 has worked fine and now displaying 12:51:00 so I can't really see any pattern
I've probably missed something really obvious in the code here so apologies
I've just figured out the pattern. As i've put the date as January, those that the actual date is within British Summer time daylight savings, it's adding an hour onto the time. I'm not sure how i'm going to fix that as I have data spanning over several years
I think it's a tough one to fix over several years. The Arcade function ToUTC() probably wouldn't make a difference considering it's already stored in UTC and an offset is being applied for daylight savings.
How many years does the data span? A Field Calculation could run to take an hour off any datetimes within the BST window.
The data spans from 2015 - 2022 currently, but each year we will be getting more data. Apologies for my delayed response as well. It seems i'm not getting notified if someones replied
I think you could fairly quickly manually adjust the datetimes by finding out the BST period for each year, selecting those affected records and take an hour off using field calculator on those selected records
DateAdd(yourDateField, -1, 'hours');