Add date interval to timestamp : INTERVAL « PL SQL Data Types « Oracle PL/SQL Tutorial

Home
Oracle PL/SQL Tutorial
1.Introduction
2.Query Select
3.Set
4.Insert Update Delete
5.Sequences
6.Table
7.Table Joins
8.View
9.Index
10.SQL Data Types
11.Character String Functions
12.Aggregate Functions
13.Date Timestamp Functions
14.Numerical Math Functions
15.Conversion Functions
16.Analytical Functions
17.Miscellaneous Functions
18.Regular Expressions Functions
19.Statistical Functions
20.Linear Regression Functions
21.PL SQL Data Types
22.PL SQL Statements
23.PL SQL Operators
24.PL SQL Programming
25.Cursor
26.Collections
27.Function Procedure Packages
28.Trigger
29.SQL PLUS Session Environment
30.System Tables Data Dictionary
31.System Packages
32.Object Oriented
33.XML
34.Large Objects
35.Transaction
36.User Privilege
Oracle PL/SQL Tutorial » PL SQL Data Types » INTERVAL 
21.8.14.Add date interval to timestamp
SQL>
SQL> DECLARE
  2     v_college_deadline TIMESTAMP;
  3  BEGIN
  4     v_college_deadline := TO_TIMESTAMP('06/06/2004', 'DD/MM/YYYY')
  5                           + INTERVAL '12-3' YEAR TO MONTH
  6                           + INTERVAL '19 9:0:0.0' DAY TO SECOND;
  7
  8     DBMS_OUTPUT.PUT_LINE('My daughter leaves for college in '
  9                          ||v_college_deadline);
 10  END;
 11  /
My daughter leaves for college in 25-SEP-16 09.00.00.000000 AM

PL/SQL procedure successfully completed.

SQL>
SQL>
21.8.INTERVAL
21.8.1.INTERVAL includes two datatypes that allow you to set appropriate durations more precisely
21.8.2.Interval value expressions
21.8.3.DAY TO SECOND examples
21.8.4.workarounds for defining intervals
21.8.5.Add some years and months
21.8.6.Add some days, hours, minutes, and seconds
21.8.7.Add 1 year, 2 months, 3 days, 4 hours, 5 minutes, 6.7 seconds
21.8.8.Adding and subtracting intervals
21.8.9.Interval multiplication
21.8.10.length of service for INTERVAL YEAR TO MONTH
21.8.11.Show some interval division
21.8.12.Storing elapsed time with INTERVAL DAY TO SECOND
21.8.13.Use INTERVAL types
21.8.14.Add date interval to timestamp
21.8.15.Double the interval
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.