Datetime and Interval Data Types

Both datetimes and intervals are made up of fields. The values of these fields determine the value of the data type.

The datetime data types are:

  • DATE

  • TIME

  • TIME WITH TIME ZONE

  • TIMESTAMP

  • TIMESTAMP WITH TIME ZONE

  • TIMESTAMP WITH LOCAL TIME ZONE

Values of datetime data types are sometimes called datetimes. In the following descriptions of the datetime data types you will see that, except for DATE, you are allowed to optionally specify a value for fractional_second_precision. The fractional_second_precision specifies the number of digits stored in the fractional part of the SECOND datetime field. When you create a column of this data type, the value can be a number in the range 0 to 9. The default is 6.

The interval data types are:

  • INTERVAL YEAR TO MONTH

  • INTERVAL DAY TO SECOND

Values of interval data types are sometimes called intervals. The INTERVAL YEAR TO MONTH data type lets you optionally specify a value for year_precision. The year_precision value is the number of digits in the YEAR datetime field. The default value is 2.

The INTERVAL DAY TO SECOND data type lets you optionally specify values for day_precision and fractional_second_precision. The day_precision is the number of digits in the DAY datetime field. Accepted values are 0 to 9. The default is 2. The fractional_second_precision specifies the number of digits stored in the fractional part of the SECOND datetime field. When you create a column of this data type, the value can be a number in the range 0 to 9. The default is 6.

See Also: