Escolar Documentos
Profissional Documentos
Cultura Documentos
htm
http://www.java2s.com/Tutorials/Database/Oracle_Date_Time_Function/index.htm
https://docs.oracle. com/cd/B19306_01/server.102/b14225/ch4datetime.htm
------------------------------------------------------------------------------------------------------------------------------13.Date Timestamp Functions
13.1.Introduction( 7 )
13.2.ADD_MONTHS( 11 )
13.3.CURRENT_DATE( 1 )
13.4.CURRENT_TIMESTAMP( 2 )
13.5.DBTIMEZONE( 1 )
13.6.EXTRACT( 15 )
13.7.FROM_TZ( 1 )
13.8.LAST_DAY( 6 )
13.9.LOCALTIMESTAMP( 1 )
13.10.MONTHS_BETWEEN( 6 )
13.11.NEW_TIME( 3 )
13.12.NEXT_DAY( 7 )
13.13.NUMTODSINTERVAL( 5 )
13.14.NUMTOYMINTERVAL( 3 )
13.15.ROUND( 8 )
13.16.SESSIONTIMEZONE( 1 )
13.17.SYSDATE( 9 )
13.18.SYSTIMESTAMP( 1 )
13.19.SYS_EXTRACT_UTC( 1 )
13.20.TO_CHAR( 13 )
13.21.TO_DATE( 16 )
13.22.TO_TIMESTAMP( 1 )
13.23.TO_TIMESTAMP_TZ( 5 )
13.24.TRUNC( 10 )
13.25.TZ_OFFSET( 1 )
13.26.Date Arithmetic( 6 )
------------------------------------------------------------------------------------------------------------------------------13.Date Timestamp Functions
13.1.Introduction( 7 )
13.1.1.
Using Datetime Functions
13.1.2.
Timestamp-Related Functions
13.1.3.
Time Interval Related Functions
13.1.4.
Date Functions
13.1.5.
LAST_DAY, TO_CHAR, TO_DATE
13.1.6.
select date '1954-08-11' + 10000 as 10,000 days
13.1.7.
Differences Between Dates
13.2.ADD_MONTHS( 11 )
13.2.1.
ADD_MONTHS(x, y) gets the result of adding y months to x.
13.2.2.
Subtract 13 months from the January 1, 2005
13.2.3.
Combine ADD_MONTHS() function with To_Date
13.2.4.
Combine ADD_MONTHS() with TO_CHAR() and TO_DATE
13.2.5.
SELECT ADD_MONTHS('28-NOV-05', 1) FROM DUAL;
13.2.6.
SELECT ADD_MONTHS('29-NOV-05', 1) FROM DUAL;
13.2.7.
SELECT ADD_MONTHS('30-NOV-05', 1) FROM DUAL;
13.2.8.
SELECT ADD_MONTHS('31-DEC-05', -1) FROM DUAL;
13.2.9.
SELECT ADD_MONTHS('01-JAN-2005', 3) FROM dual;
13.2.10.SELECT ADD_MONTHS('01-JAN-2005', -3) FROM dual; (2)
13.2.11.Add Negative time
13.3.CURRENT_DATE( 1 )
13.3.1.
Getting the Current Date in the Session Time Zone
13.4.CURRENT_TIMESTAMP( 2 )
13.4.1.
CURRENT_TIMESTAMP()
13.4.2.
Insert a row using the CURRENT_TIMESTAMP function for both columns:
13.5.DBTIMEZONE( 1 )
13.5.1.
Get the database time zone using the DBTIMEZONE() function
13.6.EXTRACT( 15 )
13.6.1.
EXTRACT() to extract and return a year, month, day, hour, minute,
second, or time zone from
the timestamp types or a DATE.
13.6.2.
SELECT EXTRACT(MONTH FROM TO_DATE('01-JAN-2005 19:15:26','DDMON-YYYY HH24:MI:SS'))
As MONTH
13.6.3.
SELECT EXTRACT(YEAR FROM TO_DATE('01-JAN-2005 19:15:26','DDMON-YYYY HH24:MI:SS')) AS
YEAR
13.6.4.
EXTRACT() gets the hour, minute, and second from a TIMESTAMP
returned by TO_TIMESTAMP()
13.6.5.
EXTRACT(MINUTE FROM TO_TIMESTAMP('01-JAN-2005 19:15:26', 'DDMON-YYYY HH24:MI:SS'))
AS MINUTE
13.6.6.
EXTRACT(SECOND FROM TO_TIMESTAMP('01-JAN-2005 19:15:26', 'DDMON-YYYY HH24:MI:SS'))
AS SECOND
13.6.7.
EXTRACT()gets the time zone hour, minute, second, region, and region
abbreviation from a
TIMESTAMP WITH TIMEZONE returned by TO_TIMESTAMP_TZ()
13.6.8.
EXTRACT(TIMEZONE_MINUTE FROM TO_TIMESTAMP_TZ('01-JAN-2005
19:15:26 -7:15', 'DDMON-YYYY HH24:MI:SS TZH:TZM'))
13.6.9.
EXTRACT(TIMEZONE_REGION FROM TO_TIMESTAMP_TZ('01-JAN-2005
19:15:26 PST', 'DD-MONYYYY HH24:MI:SS TZR'))
13.6.10.EXTRACT(TIMEZONE_ABBR FROM TO_TIMESTAMP_TZ('01-JAN-2005 19:15:26
PST', 'DD-MONYYYY HH24:MI:SS TZR'))
13.6.11.extract year from birthday
13.6.12.extract month from birthday
13.26.Date Arithmetic( 6 )
13.26.1.Using Date Arithmetic
13.26.2.Subtracts two days from August 2, 2003
13.26.3.Subtract one date from another, yielding the number of days between the
two dates.
13.26.4.select date '1996-01-29' + interval '1' month as col_1
13.26.5.select date '1997-08-11' - interval '3' month as col_3
13.26.6.Second Tuesday of the Month