12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Storing Datetime Data5.4.1.2 Using the TIMESTAMP Data TypeUse the TIMESTAMP data type to store values that are precise to fractional seconds. Anapplication that must decide which of two events occurred first might useTIMESTAMP.5.4.1.3 Using the TIMESTAMP WITH TIME ZONE Data TypeBecause TIMESTAMP WITH TIME ZONE can also store time zone information, it isparticularly suited for recording date information that must be gathered orcoordinated across geographic regions.5.4.1.4 Using the TIMESTAMP WITH LOCAL TIME ZONE Data TypeUse TIMESTAMP WITH LOCAL TIME ZONE when the time zone is not significant. Forexample, you might use it in an application that schedules teleconferences, whereparticipants each see the start and end times for their own time zone.The TIMESTAMP WITH LOCAL TIME ZONE type is appropriate for two-tierapplications in which you want to display dates and times that use the time zone ofthe client system. It is generally inappropriate in three-tier applications because datadisplayed in a Web browser is formatted according to the time zone of the Web server,not the time zone of the browser. The Web server is the database client, so its local timeis used.5.4.1.5 Representing the Difference Between Datetime ValuesUse the INTERVAL DAY TO SECOND data type to represent the precise differencebetween two datetime values. For example, you might use this value to set a reminderfor a time 36 hours in the future or to record the time between the start and end of arace. To represent long spans of time with high precision, you can use a large value forthe days portion.Use the INTERVAL YEAR TO MONTH data type to represent the difference betweentwo datetime values, where the only significant portions are the year and the month.For example, you might use this value to set a reminder for a date 18 months in thefuture, or check whether 6 months have elapsed since a particular date.<strong>Oracle</strong> Database stores dates in its own internal format which is fixed-length fields ofseven bytes each, corresponding to century, year, month, day, hour, minute, andsecond.5.4.2 Manipulating the DATE and TIME FormatsFor input and output of dates, the standard <strong>Oracle</strong> Database default date format isDD-MON-RR. The RR datetime format element enables you store 20th century dates inthe 21st century by specifying only the last two digits of the year.Time is stored in a 24-hour format as HH24:MI:SS. By default, the time in a DATEcolumn is 12:00:00 A.M. (midnight) if no time portion is entered or if the DATE istruncated. In a time-only entry, the date portion defaults to the first day of the currentmonth.You can change the current default date or time format for a specific date or timestampwith the use the TO_DATE or TO_TIMESTAMP function with a format mask, such as:TO_DATE('27-OCT-98', 'DD-MON-RR')TO_DATE('15-NOV-05 10:56 A.M.','DD-MON-YY HH:MI A.M.')TO_TIMESTAMP ('10-Sep-05 14:10:10.123000','DD-Mon-RR HH24:MI:SS.FF')5-6 <strong>SQL</strong> <strong>Developer</strong> Online Help

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!