How To: Work with dates


Date fields can be queried and displayed using ArcIMS 3.1. Values in date fields can be used:
· In a query
· In an ArcXML request
· As label text
· In map renderers


  • Querying on dates:
    Queries on date fields are supported in the Query Builder. The Query Builder supports queries on dates “before” using the less than (<) operator, “at” using the equal (=) operator, or “after” using the greater than sign (>) with a specified date. You can use the Query Builder in ArcExplorer—Java Edition, the Java Viewers, or the HTML Viewer.

    Dates can be queried in ArcXML requests. ArcXML requests are sent directly to the ArcIMS Spatial Server. Because these requests are sent directly to the Spatial Server, the syntax for specifying dates is slightly different. To query date fields in ArcXML, use
    {ts 'YYYY-MM-DD hh:mi:ss'}

    ts: timestamp
    YYYY Year Required Use four digits for the year.
    MM Month (01-12) Required Use two digits for the month. March is 03.
    DD Day (01-31) Required Use two digits for the day. The fourth is 04.
    Hh Hour (00-23) Optional Use a 24-hour clock. 8 a.m. is 08, and 8 p.m. is 20.
    Mi Minutes (00-59) Optional Use two digits for the minutes. If minutes is used, hours must also be included.
    Ss Seconds (00-59) Optional Use two digits for the seconds. If seconds is used, hours and minutes must also be included.

    The year, month, and day are separated by a dash (-). The hour, minutes, and seconds are separated by a colon (:). The date is enclosed in single quotes (') inside curly brackets ({}).
  • Shapefiles:
    Shapefiles do not support time values. The date field in a shapefile is only 8 bytes long. The 8 bytes are stored as a string of text. The text is stored as year, month, and day or YYYYMMDD. (For a complete description of the dbase file see http://www.dbase.com/knowledgebase/int/db7%5Ffile%5Ffmt.htm.) In sum, shapefiles cannot be used for time value queries. In both cases, midnight of the date specified in the query is assumed.
  • ArcSDE for Coverages:
    Date queries on layers in ArcSDE for Coverages are not supported.
  • ArcSDE layers:
    ArcSDE layers can be queried on date and time. Dates are defined as datatype in databases and, therefore, may include date and time as a valid value. When time is specified, an exact match of date and time is used.

    An example of a date query on an ArcSDE layer for 9:18 p.m. on March 8, 2002 is
    <QUERY where="ARCSDE.TABLE.MYDATE = {ts '2002-03-08 21:18:00'}" />

    Note that it does not matter which database ArcSDE is running on. ArcSDE may be running on an Oracle, SQL Server, Informix or DB2 database. The syntax, ts(date string’) is the same. ArcIMS 3.1 automatically configures the date string you create to match the syntax of the date string the database expects.

    On a shapefile, a similar query would appear as
    <QUERY where="MYShapeDATE = {ts '2002-03-08'}" />

    Note that the time is not specified.
  • Displaying dates:
    Date fields can be displayed as labels on points, lines or polygons. Date fields can also be used for classifying features with unique or graduated values. The Layer Properties dialog in Author or ArcExplorer 3 can be used to create maps that show unique date values. To create maps based on graduated values of dates, or ranges of dates, the ArcXML file must be manually edited in a text or XML editor. An example of an ArcXML file that creates graduated symbols for dates follows:
    <VALUEMAPRENDERER lookupfield="test_date">
    <RANGE lower="{ts '1111-01-31 00:00:00'}" upper="{ts '1400-09-01 00:00:00'}" label="Less than 10751.809">
    <SIMPLEPOLYGONSYMBOL boundarytransparency="1.0" filltransparency="1.0" fillcolor="255,255,0" boundarycaptype="round" />
    <RANGE lower="{ts '1400-09-02 00:00:00'}" upper="{ts '2001-04-25 00:00:00'}" label="1400-09-02 – 2001-04-25">
    <SIMPLEPOLYGONSYMBOL boundarytransparency="1.0" filltransparency="1.0" fillcolor="255,170,0" boundarycaptype="round" />