Home » SQL & PL/SQL » SQL & PL/SQL » How to add minutes to date? (10204)
How to add minutes to date? [message #436945] Tue, 29 December 2009 12:49 Go to next message
bella13
Messages: 90
Registered: July 2005
Member
I am having trouble deriving the following. ANy clues/ help?

I want to add minutes to a date type.

To sysdate which is Dec 29 2009 1:00 PM I want to be able to add

- 10 minutes which should result output : Dec 29 2009 1:10 PM
- 90 minutes which should result output : Dec 29 2009 2:30 PM
- 1440 minutes which should result output : Dec 30 2009 1:00 PM

thanks,
Re: How to add minutes to date? [message #436946 is a reply to message #436945] Tue, 29 December 2009 12:55 Go to previous messageGo to next message
joy_division
Messages: 4641
Registered: February 2005
Location: East Coast USA
Senior Member
Hint: There are 86400 seconds in a day and 60 seconds in a minute.

[edit] oops, I meant seconds, not minutes. fixed.

[Updated on: Tue, 29 December 2009 12:58]

Report message to a moderator

Re: How to add minutes to date? [message #436947 is a reply to message #436945] Tue, 29 December 2009 13:10 Go to previous messageGo to next message
Michel Cadot
Messages: 64130
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
In Oracle, date arithmetic is in unit of day (that is 1 is 1 day), and as you said there are 1440 minutes in a day.

Regards
Michel

[Updated on: Tue, 29 December 2009 13:11]

Report message to a moderator

Re: How to add minutes to date? [message #436958 is a reply to message #436945] Tue, 29 December 2009 21:51 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
Use INTERVAL data type.

regards,
Delna
Re: How to add minutes to date? [message #436961 is a reply to message #436958] Tue, 29 December 2009 23:45 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
How about this ?
We can do it with date arithmetic. The hint is already given.


 

hr@orafaq> select to_char(sysdate,'dd/mm/yyyy hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'DD
-------------------
30/12/2009 11:13:37

Elapsed: 00:00:00.00
hr@orafaq> select to_char(sysdate + 30/1440,'dd/mm/yyyy hh24:mi:ss') from dual;

TO_CHAR(SYSDATE+30/
-------------------
30/12/2009 11:43:53

Elapsed: 00:00:00.00
hr@orafaq> 

[Updated on: Tue, 29 December 2009 23:48]

Report message to a moderator

Re: How to add minutes to date? [message #436981 is a reply to message #436961] Wed, 30 December 2009 02:12 Go to previous message
Michel Cadot
Messages: 64130
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
The hint is already given.

So let OP works by himself and come back if he has any problem.
No need to go against other posters; it is clear we want him to find it, isn't it?

Regards
Michel
Previous Topic: How '>' behaves while doing string comparison?
Next Topic: masking card number first 10 ten digits (merged)
Goto Forum:
  


Current Time: Wed Dec 07 06:56:57 CST 2016

Total time taken to generate the page: 0.14620 seconds