Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add/Subtract Interval from TIMESTAMP

Maithily-OracleSep 28 2012 — edited Oct 1 2012
Hi All,

I have a requirement to subtract number of days or months or weeks from a Timestamp column and get a timestamp value in return.

Assume I have the following table -
Table Name : Test
Columns:
Effective_End_Date : TIMESTAMP
Interval_type : VARCHAR2
Interval_value : NUMBER

Typically, one would go with the following query -

Select Effective_End_Date - Interval '1' DAY from test;

The issue is for I have to subtract the value stored in interval_value stored in the table from the effective_end_date. Also, the interval type (DAY, MONTH, etc) is stored in the INTERVAL_TYPE.

Could anyone suggest any query for this? Let me know if more inputs are required.

Thanks,
Maithily.
This post has been answered by Frank Kulash on Sep 29 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 29 2012
Added on Sep 28 2012
11 comments
12,244 views