2.2.4 Date/Time TypesThe following discussion of the date/time types assumes that the configuration parameter, edb_redwood_date, has been set to true whenever a table is created or altered.Advanced Server supports the date/time types shown in the following table.
[(p)] TIMESTAMP [(p)] TIMESTAMP [(p)] WITH TIME ZONE When DATE appears as the data type of a column in the data definition language (DDL) commands, CREATE TABLE or ALTER TABLE, it is translated to TIMESTAMP(0) at the time the table definition is stored in the database. Thus, a time component will also be stored in the column along with the date.When DATE appears as a data type of a variable in an SPL declaration section, or the data type of a formal parameter in an SPL procedure or an SPL function, or the return type of an SPL function, it is always translated to TIMESTAMP(0) and thus can handle a time component if present.TIMESTAMP accepts an optional precision value p which specifies the number of fractional digits retained in the seconds field. The allowed range of p is from 0 to 6 with the default being 6.When TIMESTAMP values are stored as double precision floating-point numbers (currently the default), the effective limit of precision may be less than 6. TIMESTAMP values are stored as seconds before or after midnight 2000-01-01. Microsecond precision is achieved for dates within a few years of 2000-01-01, but the precision degrades for dates further away. When TIMESTAMP values are stored as eight-byte integers (a compile-time option), microsecond precision is available over the full range of values. However eight-byte integer timestamps have a more limited range of dates than shown above: from 4713 BC up to 294276 AD.TIMESTAMP (p) WITH TIME ZONE is similar to TIMESTAMP (p), but includes the time zone as well.220.127.116.11 INTERVAL TypesINTERVAL values specify a period of time. Values of INTERVAL type are composed of fields that describe the value of the data. The following table lists the fields allowed in an INTERVAL type:
0 through 59.9(p) where 9(p) is the precision of fractional secondsThe fields must be presented in descending order – from YEARS to MONTHS, and from DAYS to HOURS, MINUTES and then SECONDS.Advanced Server supports two INTERVAL types compatible with Oracle databases.The first variation supported by Advanced Server is INTERVAL DAY TO SECOND [(p)]. INTERVAL DAY TO SECOND [(p)] stores a time interval in days, hours, minutes and seconds.p specifies the precision of the second field.as 2 hours, 34 minutes, 56 seconds and 13 thousandths of a second. Note that the fractional second is rounded up to 13 because of the specified precision.The second variation supported by Advanced Server that is compatible with Oracle databases is INTERVAL YEAR TO MONTH. This variation stores a time interval in years and months.18.104.22.168 Date/Time InputDate and time input is accepted in ISO 8601 SQL-compatible format, the Oracle default dd-MON-yy format, as well as a number of other formats provided that there is no ambiguity as to which component is the year, month, and day. However, use of the TO_DATE function is strongly recommended to avoid ambiguities.Any date or time literal input needs to be enclosed in single quotes, like text strings. The following SQL standard syntax is also accepted:type 'value'type is either DATE or TIMESTAMP.value is a date/time text string.22.214.171.124.1 DatesThe following table shows some possible input formats for dates, all of which equate to January 8, 1999.
The date values can be assigned to a DATE or TIMESTAMP column or variable. The hour, minute, and seconds fields will be set to zero if the date value is not appended with a time value.126.96.36.199.2 Times
188.8.131.52.3 Time StampsValid input for time stamps consists of a concatenation of a date and a time. The date portion of the time stamp can be formatted according to any of the examples shown in Table 3‑2‑6 Date Input. The time portion of the time stamp can be formatted according to any of examples shown in Table 3‑2‑7 Time Input.The following is an example of a time stamp which follows the Oracle default format.The following is an example of a time stamp which follows the ISO 8601 standard.184.108.40.206 Date/Time OutputThe default output format of the date/time types will be either (dd-MON-yy) referred to as the Redwood date style, compatible with Oracle databases, or (yyyy-mm-dd) referred to as the ISO 8601 format, depending upon the application interface to the database. Applications that use JDBC such as SQL Interactive always present the date in ISO 8601 form. Other applications such as PSQL present the date in Redwood form.
220.127.116.11 InternalsAdvanced Server uses Julian dates for all date/time calculations. Julian dates correctly predict or calculate any date after 4713 BC based on the assumption that the length of the year is 365.2425 days.