[GIS] Select by Attributes Where Clause how to get current date

arcgis-desktop

I am trying to build a where clause for a select by attributes operation in ArcGIS. I have a feature class that has a date field that has dates in it. I wish to construct a where clause that selects records from 65 years ago or more. I want this to be generic, where the clause computes the 65 years from whatever today's date is without actually entering today's date. In other words, I do NOT want to enter something for a where clause like this:

"date_field" >= date '1945-09-22'

I want to have a where clause like this:

"date_field" >= curdate() - 65 years

The problem is that I can't figure out how to write this where clause. There is nothing in the ArcGIS documentation on composing where clauses with dates that includes obtaining the current date programmatically as opposed to entering a specific date.

Help? Any input is appreciated.

Best Answer

ESRI documentation says it follows SQL 92.

SQL 92 says subtraction of dates returns number of days.

This works with a file geodatabase to select rows older than 65 years:

(current_date - "DateField") > 365.0 * 65.0
Related Question