Welcome Guest ( Log In | Register )


 
 
 
 
 
 

 
 
Oracle 

Performance Tuning Reference poster
 
Oracle training in Linux 

commands
 
Oracle training Weblogic Book
 
Easy Oracle Jumpstart
 
Oracle training & performance tuning books
 
Burleson Consulting Remote DB Administration
 
 
 
Reply to this topicStart new topic
> Storing Dynamic Dates?
MehItsMe
post Apr 26 2012, 05:59 PM
Post #1


Newbie
*

Group: Members
Posts: 1
Joined: 26-April 12
Member No.: 47,140



Hi all & sorry for the vague topic title.

I need to store a date that will always be x years before the current date. Is doing something like
select sysdate -x from dual
Going to result in any weird issues down the road?
Also, because I haven't explicitly specified the date, when queried, will the value always be sysdate - x (What I want to happen) as opposed to dateRowWasCreated - x?

Any pointers would be great - as you can tell I'm quite / very new to Oracle.

Cheers.
Go to the top of the page
 
+Quote Post
burleson
post Apr 27 2012, 08:05 AM
Post #2


Advanced Member
***

Group: Members
Posts: 11,610
Joined: 26-January 04
Member No.: 13



Hi

>> I need to store a date that will always be x years before the current date.

This is not data, it's really a function!

Inside Oracle, it's a PL/SQL function or a "virtual column":

http://www.dba-oracle.com/oracle11g/oracle...sed_columns.htm

I would write a PL/SQL function called years_before that accepts the years as an argument:


CODE
select years_before(10) from dual;



See here for working examples in the code download:


http://www.rampant-books.com/book_0501_easy_plsql.htm


--------------------
Hope this helps. . .

Donald K. Burleson
Oracle Press author
Author of Oracle Tuning: The Definitive Reference
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st October 2014 - 08:34 PM