1

I have a field with numbers in it (concentration of chemical compounds that were presented in aquatic environments) and I'd like to combine them with a field which would have date type capabilities but as a unique year (e.g. 2013, 2008 etc.) instead of a whole date (2/5/2013, 5/8/2008 etc.).

The year data represent the years of chemical analysis of water samples.

The general concept of this work is to provide me finally the information of the concentration and the year of analysis of a certain compound.

Also I'd like to have the ability to select concentrations by year.

For example: before the year of 2004 what was the concentrations of these substances?

How can I achieve the above?

1
  • Is there a reason you want to store this in a date field and not just an integer field, as MappaGnosis suggests? Also, if you already have discrete dates in a date field, you don't need to separate the year out into a new field to make selections like your example. Commented Dec 8, 2016 at 16:10

2 Answers 2

1

You could just use a an integer (called year). That will do what you need. And your query in the example you give would be SELECT * from some_table WHERE year < 2004

1

The ArcGIS tool "Calculate field" can be used for that.

Set expression to

(datetime.datetime.strptime( !fulldate! , "%m/%d/%Y")).year

and the code block to

import datetime

the parser to python and the input and output fields as you like.

I recommend crerating a "year" output field and retaining the original date (which was in the fulldate column in my example).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.