

Further "behavior" includes DATE comparisons, which implies you can SORT BY, GROUP BY, find dates BETWEEN and so on, and subtraction: subtract one DATE from another to get the integer difference in days (or an INTERVAL type, when using TIMESTAMP values).Ĭonverting Between DATE Types and Strings. They possess both properties (year, month, hour etc.) and behavior, such as SELECT SYSDATE - 7 FROM dual /* e.g. If you're familiar with OOP, it may also be helpful to think of DATE types as objects. See "Date Arithmetic" below for more detail.

In such cases functions like TRUNC can be useful to round down the hours, minutes and seconds components of the two DATEs you are comparing. In some cases you may want to compare two dates on a different basis, such as the year, month or day. Typ=13 Len=8: 213,7,7,25,23,7,15,0 */Ĭomma-separated values in the result correspond to the bytes Oracle uses to store each component of a date and time, from century down to second One important note here when comparing DATE types, all the DATE's components will be compared, down to the seconds. To get a feeling for the internal representation: SELECT DUMP(SYSDATE) FROM dual /* e.g. The format is controlled by the Oracle parameter NLS_DATE_FORMAT, and can changed on a session basis (see below). Selecting the current system time using SYSDATE, which returns a value of type DATE and is the current date and time set for the operating system on which the database resides : SELECT SYSDATE FROM dual /* e.g. If you SELECT a DATE type, Oracle automatically converts it to readable string, but this is not how the value is actually been stored. It is effectively independent of any specific string format. The first thing to grasp about the DATE type in Oracle is that its internal representation allows it to be displayed and manipulated in many different ways. (For more background about TIMESTAMP and INTERVAL types, read Jonathan Gennick's Oracle Magazine articles "Datetime Datatypes Add Precision" and " Finding the Time in Between" (both published in the Nov.-Dec. The focus here will be on the DATE type, although much that applies to DATE also applies to TIMESTAMP.

Dates can be anywhere in the range from JanuB.C., to DecemA.D. A value stored in a DATE field contains "components" corresponding to the century, year, month, day, hour, minute and second. The DATE type, which represents a date and time.
