Output time data only as fieldtype TIME

356
4
Jump to solution
02-23-2021 04:53 PM
JulietK
Occasional Contributor

Hi, I have a hidden field (TimeCopy) with calculate format-date(${InterceptTime}, '%H:%M') to extract the time only from a DateTime field. The field automatically outputs to field type String, which doesn’t display the way I need it to when displayed in a serial chart format in the Dashboard. Each timestamps are shown as one bar in the chart, so 18:25 and 18:30 would be separate bars as below. I need a chart to show in hourly ranges, with every entry within the same hour counted and displayed in a single bar.

JulietK_0-1614127806773.png

I tried creating a serial chart with just the datetime field instead, with Parse dates ticked and minimum set as Hour. This still displays all the different dates as well, so doesn’t return what I am looking for.

JulietK_1-1614127806780.png

 

Is there a way to get the Time field (time only extracted from a DateTime field) to output as just Time, and not string? I’ve tried setting the bind::esri:fieldtype as esriFieldTypeDate, or bind::type as Time, but in either cases the field does not output any data.

Below is an example of what I am trying to achieve.

JulietK_2-1614127806786.png

 

The DateTime field needs to be kept as DateTime, as I’ve set it up to calculate ‘time elapsed’ between two DateTime fields.

It seems maybe in the TimeCopy field, I could find a way to replace all the dates from the DateTime with a default date, so that when I select Parse Dates and Minimum Period as Hour, only the hours of the day are displayed like the above.

Though I know the end result I would like, I’m unsure how to replace the date from DateTime and copy the time from the DateTime together into the same field? Or whether there is an easier way to turn the TimeCopy field into a Time only fieldtype?

 

Thank you, any ideas/advice would be very much appreciated!

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Regular Contributor

Oh, you're right, I didn't think about that.

For the arbitrary date, just hard-code a value into the formula in the standard YYYY-MM-DD format.

format-date(${InterceptTime}, '1970-01-01 %H:%M') 

jcarlson_0-1614196144522.png

 

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
4 Replies
jcarlson
MVP Regular Contributor

I think the arbitrary date idea is doable, and gives you the option of getting finer resolution if you ever wanted.

If you only need it grouped by hour, why not make "TimeCopy" extract the hour only? Either format-date(${InterceptTime}, '%H:00')  or even just '%H'?

- Josh Carlson
Kendall County GIS
0 Kudos
JulietK
Occasional Contributor

Hi Josh, thank you for your response! Any idea how I could copy the time into the TimeCopy field with an arbitrary date? 

The copy of hours only is a great idea, but the only issue is that like the first graph image, the hours with no entries for will not show up - e.g. 0700 won't show up on the graph if there are no entries between 0700 and 0759. 

 

Thank you again!

0 Kudos
jcarlson
MVP Regular Contributor

Oh, you're right, I didn't think about that.

For the arbitrary date, just hard-code a value into the formula in the standard YYYY-MM-DD format.

format-date(${InterceptTime}, '1970-01-01 %H:%M') 

jcarlson_0-1614196144522.png

 

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
JulietK
Occasional Contributor

Hi Josh, that is perfect, thank you for that! 🙂