Home » RDBMS Server » Server Administration » Date Functions
Date Functions [message #370466] Tue, 30 November 1999 11:11 Go to next message
Matthew Jenkins
Messages: 1
Registered: November 1999
Junior Member
Dear All,

(have already posted this on the Oracle Server Board - apologies to all the dbas!!)

I am fairly new to Oracle although have been working with Sybase and MSSQLServer for a few years. Oracle seems to have a distinct lack of system functions for manipulating dates, such as a day_add function and the like. Does anyone have any code already written or know of an existing list of functions that I could use. This would save me the trouble of writing them myself. If not, I will post my code on the list next week !!!

Cheers
Matt
Re: Date Functions [message #370468 is a reply to message #370466] Tue, 30 November 1999 11:41 Go to previous messageGo to next message
Cindy
Messages: 88
Registered: November 1999
Member
To add 1 day to a particular date:

select sysdate + 1 from dual;

or to format it:

select to_char(sysdate + 1,'yyyy-mm-dd') from dual;

(replace sysdate by your date column)
Re: Date Functions [message #370469 is a reply to message #370466] Tue, 30 November 1999 11:41 Go to previous messageGo to next message
Cindy
Messages: 88
Registered: November 1999
Member
To add 1 day to a particular date:

select sysdate + 1 from dual;

or to format it:

select to_char(sysdate + 1,'yyyy-mm-dd') from dual;

(replace sysdate by your date column and dual
by your table name)
Re: Date Functions [message #370470 is a reply to message #370466] Tue, 30 November 1999 11:52 Go to previous message
Cindy again
Messages: 1
Registered: November 1999
Junior Member
Also, you can do the same kind of thing with any
part of a date/timestamp, always basing it on the
number of (hours, minutes, seconds) in 24 hours.

To add 5 hours to a date:

select to_char(sysdate + 5/24,'yyyymmdd hh24miss') from dual;

To add 60 seconds to a date:

select to_char(sysdate + 60/86400,'yyyymmdd hh24miss') from dual;

To add 1 1/2 days to a date:

select to_char(sysdate + 36/24,'yyyymmdd hh24miss') from dual;

No reason to write your own, the functionality is
already there, just not documented well.
Previous Topic: any known problems with rebuilding indexes?
Next Topic: III try about CNTL_BREAK, I'm not too bad about it !!!
Goto Forum:
  


Current Time: Thu Mar 28 12:52:33 CDT 2024