3. Understanding SQL Data Types : SQL Data Types : Date and Time Data Types : Ingresdate Data Types
 
Share this page                  
Ingresdate Data Types
The ingresdate data type is an abstract data type. The ingresdate data type input formats are as follows:
Absolute date
Absolute time
Combined date and time
Time interval
Ingresdate Input
Ingresdate values are specified as quoted character strings. A date can be entered by itself or with a time value. If a date is entered without the time, no time is shown when the data displays (see page How Ingres Dates and Times Are Displayed).
Because ingresdate can store different forms of date, time, and interval information, the nature of the value is determined by the input format.
Ingresdate absolute formats recognized are determined by the active date format, which can be altered to suit particular country preferences.
Ingresdate interval forms follow a simple form that is distinct from the absolute forms.
II_DATE_FORMAT for Absolute Ingresdate
The II_DATE_FORMAT setting determines the legal formats for absolute ingresdate values. The default setting is US.
II_DATE_FORMAT can be set on a session basis. For information on setting II_DATE_FORMAT, see the System Administrator Guide.
The following table lists ingresdate input and output formats:
Setting
Valid Input Formats
Output Format
US (default)
mm/dd/yy
mm-dd-yy
mmddyy
mm/dd/yyyy
mm-dd-yyyy
mmddyyyy
dd-mmm-yyyy
dd mmm yyyy
yyyy-mm-dd
yyyy.mm.dd
yyyy_mm_dd
mm-dd
mm/dd
dd-mmm-yyyy
MULTINATIONAL
yyyy-mm-dd
mm-dd-yy
mmddyy
mmddyyyy
dd/mm/yy
dd/mm/yyyy
dd mmm yyyy
All US formats except mm/dd/yyyy and mm/dd/yy
dd/mm/yy
MULTINATIONAL4
yyyy-mm-dd
dd/mm/yy
dd/mm/yyyy
dd mmm yyyy
mm-dd-yy
mmddyy
mmddyyyy
All US formats except mm/dd/yyyy and mm/dd/yy
dd/mm/yyyy
ISO
yyyy-mm-dd
yyyymmdd
yymmdd
ymmdd
mmdd
mdd
dd mmm yyyy
All US input formats except mmddyy
yymmdd
ISO4
yyyy-mm-dd
yyyymmdd
yymmdd
ymmdd
mmdd
mdd
dd mmm yyyy
All US input formats except mmddyy
yyyymmdd
ISO4T
All ISO4 input formats.
If the prefix "T" is used then the absolute time component can use the input format hhmmss as well as the standard hh:mm:ss. For example:
Acceptable: yyyymmddThhmmss, yyyymmddThh:mm:ss, and yyyymmdd hh:mm:ss
Not acceptable:
yyyymmdd hhmmss
Acceptable:
'Thhmmss', 'Thh:mm:ss' and 'hh:mm:ss'
Not acceptable:
'hhmmss'
This is the only case where an absolute time can be entered in format hhmmss instead of hh:mm:ss. To avoid ambiguity, a time field entered in hhmmss format must be 6 characters long.
yyyymmdd
ISO4 output format, unless the date includes a time, in which case the format is: yyyymmddThhmmss
ISO4TC
See description under ISO4T.
ISO4 output format, unless the date includes a time, in which case the format is:
yyyymmddThh:mm:ss
SWEDEN or FINLAND
yyyy-mm-dd
yy-mm-dd
mmddyy
dd mmm yyyy
All US input formats
except mm-dd-yyyy
yyyy-mm-dd
GERMAN
yyyy-mm-dd
dd.mm.yyyy
ddmmyy
dmmyy
dmmyyyy
ddmmyyyy
dd mmm yyyy
mm-dd-yy
All US input formats except yyyy.mm.dd and mmddyy
dd.mm.yyyy
YMD
mm/dd
mm-dd
mmdd
yymdd
yymmdd
yy-mm-dd
yyyymdd
yyyy-mmm-dd
yyyy/mm/dd
yyyy.mm.dd
yyyy-mm-dd
yyyy_mm_dd
yyyymmdd
yyyy mmm dd
yyyy-mmm-dd
DMY
yyyy-mm-dd
yyyy_mm_dd
dd/mm
dd-mm
ddmm
ddmyy
dd-mm-yy
ddmmyy
ddmyyyy
ddmmyyyy
dd/mm/yyyy
dd-mm-yyyy
dd.mm.yyyy
dd-mmm-yyyy
dd mmm yyyy
dd-mmm-yyyy
MDY
yyyy-mm-dd
yyyy_mm_dd
mm/dd
mm-dd
mmdd
mmddyy
mddyy
mddyyyy
mm-dd-yy
mm-dd-yyyy
mm/dd/yyyy
mm.dd.yyyy
mmddyyyy
mmm-dd-yyyy
mmm-dd-yyyy
Year defaults to the current year. In formats that include delimiters (such as forward slashes or dashes), specify the last two digits of the year; the first two digits default to the current century (2000). For example, if this date is entered:
'03/21/03'
using the format mm/dd/yyyy, the DBMS Server assumes that you are referring to March 21, 2003.
In three-character month formats, for example, dd-mmm-yy, specify three-letter abbreviations for the month (for example, mar, apr, may).
To specify the current system date, use the constant, today. For example:
SELECT DATE('TODAY');
To specify the current system date and time, use the constant, now.
For convenience, the ANSI date/time formats are also accepted as input to ingresdates.
II_DATE_CENTURY_BOUNDARY for Absolute Ingresdate
The II_DATE_CENTURY_BOUNDARY variable, which can be set to an integer in the 0< n <=100 range, dictates the implied century for an ingresdate value when only the last two digits of the year are entered.
For example, if II_DATE_CENTURY_BOUNDARY is 50 and the current year is 1999, an input date of 3/17/51 is treated as March 17, 1951, but a date of 03/17/49 is treated as March 17, 2049.
If the II_DATE_CENTURY_BOUNDARY variable is not set or if it is set to 0 or 100, the current century is used. If the user enters the full four digits for the year in a four-digit year field in the application, the year is accepted as entered, regardless of the II_DATE_CENTURY_BOUNDARY setting.
Absolute Time Input for Ingresdate
The format for inputting an absolute time into an ingresdate value is:
'hh:mm[:ss] [am|pm] [timezone]'
Input formats for absolute times are assumed to be on a 24-hour clock. If a time with the designation am or pm is entered, the time is converted to a 24-hour internal and displayed representation.
If timezone is omitted, the local time zone designation is assumed. Times are stored as Greenwich Mean Time (GMT) and displayed using the time zone adjustment specified by II_TIMEZONE_NAME.
If an absolute time without a date is entered, the date defaults to the current system date.
Combined Date and Time Input for Ingresdate
Any valid absolute date input format can be paired with a valid absolute time input format to form a valid date and time entry in an ingresdate. The following table shows examples of valid date and time entries, using the US absolute date input formats:
Format
Example
mm/dd/yy hh:mm:ss
11/15/03 10:30:00
dd-mmm-yy hh:mm:ss
15-nov-03 10:30:00
mm/dd/yy hh:mm:ss
11/15/03 10:30:00
dd-mmm-yy hh:mm:ss gmt
15-nov-03 10:30:00 gmt
dd-mmm-yy hh:mm:ss [am|pm]
15-nov-03 10:30:00 am
mm/dd/yy hh:mm
11/15/03 10:30
dd-mmm-yy hh:mm
15-nov-03 10:30
mm/dd/yy hh:mm
11/15/03 10:30
dd-mmm-yy hh:mm
15-nov-03 10:30
Interval Input for Ingresdate
Ingres interval data includes date intervals, time intervals, or a combination.
An ingresdate interval value is entered as a quoted string of qualified numbers that mark the units of the interval. For example 18 months might be represented as:
'1 year 6 months'
The interval syntax is of the form:
'[ n YEARS][ n MONTHS][ n DAYS][ n HOURS][ n MINUTES][n SECONDS]'
where n can be a positive or negative integer. The interval qualifiers can be abbreviated:
 
Interval
Abbreviation
YEARS
YEAR, YRS, YR
QUARTERS
QUARTERS, QTRS, QTR
MONTHS
MONTH, MOS, MO
WEEKS
WEEK, WKS, WK
DAYS
DAY
HOURS
HOURS, HRS, HR
MINUTES
MINUTE, MINS, MIN
SECONDS
SECOND, SECS, SEC
Here are example date intervals:
'5 years'
'8 months'
'14 days'
'5 yrs 8 mos 14 days'
'5 years 8 months'
'5 years 14 days'
'8 months 14 days'
Here are example time intervals:
'23 hours'
'38 minutes'
'53 seconds'
'23 hrs 38 mins 53 secs'
'23 hrs 53 seconds'
'28 hrs 38 mins'
'38 mins 53 secs'
'23:38 hours'
'23:38:53 hours'
If a time interval greater than 1 day is entered, the interval is converted to a date and time interval. For example:
'26 hours'
is converted to:
'1 day 2 hours'
Valid ranges for Ingres date and time intervals are:
Interval
Range
YEARS
-9999 to +9999
MONTHS
-119988 to +119988
DAYS
-3652047 to +3652047
HOURS, DAYS, SECONDS
-2,147,483,639 to +2,147,483,639
For convenience, the ANSI interval input formats can also be used for loading ingresdate intervals.
How Ingres Dates and Times Are Displayed
Absolute Dates
By default ingresdate absolute values (date, time, or timestamp) are displayed as strings of left-justified 25 characters with trailing blanks.
The display format for an absolute ingresdate is determined by the II_DATE_FORMAT (see page II_DATE_FORMAT for Absolute Ingresdate) or the SQL statement SET DATE_FORMAT (see page Date_format).
The display format for an absolute time is:
hh:mm:ss
The DBMS Server displays 24-hour times for the current time zone. Times are stored as Greenwich Mean Time (GMT) and displayed using the time zone adjustment specified by II_TIMEZONE_NAME.
If a date is not entered when entering a time, the current date is inserted in the date place. If seconds are not entered when entering a time, zeros display in the seconds place.
Intervals
By default ingresdate interval is displayed as the first 25 characters of the interval string; the remainder of the interval will be truncated. The maximum length of an ingresdate interval is 57 characters.
The complete format appears as:
[-]yy yrs [-]mm mos [-]dd days [-]hh hrs [-]mm mins [-]ss secs
What is stored in the ingresdate interval determines what is displayed in the 25 characters. By default the "least significant" portion is truncated to fit the result into the 25 characters. What is deemed as "least significant" is a function of the size of any component of the time interval. Trailing blanks are appended to fill out the string to 25 characters.
For example, if the following ingresdate interval had been inserted into an ingresdate column:
5 yrs 4 mos 3 days 12 hrs 32 min 14 secs
when selected within terminal monitor, by default, the following would be returned:
5 yrs 4 mos 3 days 12 hrs
The least significant portion of the interval, minutes and seconds, have been lost due to truncation to fit the result into 25 characters. This happens silently--there are no warnings or error messages.
To display the full string, it is necessary to cast the column to a character string of the required length. For example:
CHAR(my_interval,60)
returns the full value plus trailing spaces to the length specified in the cast:
5 yrs 4 mos 3 days 12 hrs 32 min 14 secs