Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
41
Добавлен:
16.04.2013
Размер:
4.96 Mб
Скачать

Representing Date and Time Data

See Also: Oracle Call Interface Programmer's Guide for a complete description of the Oracle Database internal date format

Date Format

For input and output of dates, the standard Oracle Database default date format is DD-MON-RR. For example:

'13-NOV-92'

To change this default date format on an instance-wide basis, use the NLS_DATE_ FORMAT parameter. To change the format during a session, use the ALTER SESSION statement. To enter dates that are not in the current default date format, use the TO_ DATE function with a format mask. For example:

TO_DATE ('November 13, 1992', 'MONTH DD, YYYY')

See Also: Oracle Database Concepts for information about Julian dates. Oracle Database Julian dates might not be compatible with Julian dates generated by other date algorithms.

Be careful using a date format like DD-MON-YY. The YY indicates the year in the current century. For example, 31-DEC-92 is December 31, 2092, not 1992 as you might expect. If you want to indicate years in any century other than the current one, use a different format mask, such as the default RR.

Checking If Two DATE Values Refer to the Same Day

To compare dates that have time data, use the SQL function TRUNC to ignore the time component.

Displaying the Current Date and Time

Use the SQL function SYSDATE to return the system date and time.

Setting SYSDATE to a Constant Value

The FIXED_DATE initialization parameter lets you set SYSDATE to a constant, which can be useful for testing.

Printing a Date with BC/AD Notation

SQL> -- By default, the date is printed without any BC or AD qualifier.

SQL> SELECT SYSDATE FROM DUAL;

Selecting a Datatype 2-21

Соседние файлы в папке Oracle 10g