Monday, May 12, 2008

how to use date in queries and selections

You need to follow some syntax rules for Date data type in ArcGIS Queries or Selections.

An example query for features selected before 1970 would be: "Datefield" < date '1970-01-01'

File geodatabase, shapefile, coverage, and other file-based data sources
Dates in file geodatabases, shapefiles, and coverages are preceded with "date".
"Datefield" = date 'yyyy-mm-dd'
File geodatabases support the use of a time in the date field, so this can be added to the expression:
"Datefield" = date 'yyyy-mm-dd hh:mm:ss'
Shapefiles and coverages do not support the use of time in a date field.


Personal geodatabase
Dates in personal geodatabases are delimited using #.
For example:
[Datefield] = #mm-dd-yyyy hh:mm:ss#
It can be shortened to [Datefield] = #mm-dd-yyyy#
An alternative format
[Datefield] = #yyyy/mm/dd#


If the dates are in Text field, you need to use Format([date_field], "dddd, MMMM dd, yyyy") or you can convert the whole text field into a new date field.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home