Year only in a date field

7868
16
04-17-2019 10:57 AM
JoeBorgione
MVP Emeritus

I have a feature class with a numeric field representing a year in the form of yyyy (2017).  ArcGIS Pro has a tool called Convert Time Field that can take an integer and write it to an existing date field or it will add one for you.

When I run the tool it returns a date in the form of 1/1/2017.  Is there a way to format a date field to show just the year?

That should just about do it....
0 Kudos
16 Replies
Egge-Jan_Pollé
MVP Regular Contributor

Hi Joe Borgione‌,

The answer to your question is, I think: No. No, not in ArcGIS Pro.

The display format for dates depends on your regional settings. ArcGIS Pro follows the Windows settings for date formats and uses the system short date format (numerical) to display dates, independent of the underlying database's format on the system.

Of course if you display your data somewhere else, e.g. in ArcGIS Online, you can choose to format your dates to only show the year.

But then I have this question: why would you convert your year values to dates to begin with? If the year really is the only thing you are interested in - and there really is no day, no month, no time to store - then maybe the numeric field you started out with would be sufficient, or not?

What do you think?

Best regards,

Egge-Jan

JoeBorgione
MVP Emeritus

why would you convert your year values to dates to begin with? It was requested of me.....

Of course if you display your data somewhere else, e.g. in ArcGIS Online, you can choose to format your dates to only show the year.

Looking at this now:  https://community.esri.com/thread/222378-text-to-date-using-arcade-expressions, it's just that we have a 'year' field that was provided as an int....

That should just about do it....
0 Kudos
by Anonymous User
Not applicable

Hi Egge-Jan,

I'm curious if one application that a user would want to use the year as a date field instead of a numeric field would be for space-time binning(?).  Say one wanted to evaluate the spatial distribution of model polygons on a landscape over many years, but the year field is numeric, would this be an instance where the user would want to convert year values to dates? And if so, is there a workflow you are familiar with to achieve that result?

Thanks,

Zachary 

DanPatterson_Retired
MVP Emeritus
0 Kudos
JoeBorgione
MVP Emeritus

hahahaha; my stupid question of the day left you speechless!

Dan Patterson

That should just about do it....
0 Kudos
DanPatterson_Retired
MVP Emeritus

now remember Arcade is an evolving language... I am sure it is just moi and not something that they didn't test on a date field

Xander Bakker‌ can you spot my error?

0 Kudos
JoeBorgione
MVP Emeritus

I'm thinking this a red herring:  one of the guys here wants to use the integer field as a year in a dashboard.  Not exactly sure what the objective is.  On to other more intangible things.... 

That should just about do it....
0 Kudos
XanderBakker
Esri Esteemed Contributor

Not sure what the error is, but if you want to strore the year in a separate field, you would create an integer field, and doing a calculation with Arcade on a date field using Year($feature.NameOfDateField) and storing the result in an integer field will just store the year value. Just tried it and it works as it is supposed to. Not sure what might be different in your case.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Funky in the field calculator using arcade on a date field

2019-04-17 8:11:55 AM 

using

Year($feature.DT_test)

yields

1905-07-11

So I would say no as well, but I am sure it is something silly or just something

0 Kudos