1

I would like to add 10 minutes to sysdate,

select to_char(SYSDATE,'dd-Mon-yyyy hh:mi:ss') + 10/1440 from dual

when I tried the above I got the error

ORA-01722: invalid number
APC
  • 144,005
  • 19
  • 170
  • 281
Jacob
  • 14,463
  • 65
  • 207
  • 320

2 Answers2

4

The error appears because you add 10/1440 to char not to date.

Try this:

select SYSDATE + 10/1440 from dual;

or

select to_char(SYSDATE+ 10/1440,'dd-Mon-yyyy hh:mi:ss')  from dual;

or

select to_char( sysdate + interval '10' minute,'dd-Mon-yyyy hh:mi:ss')  
from dual;

Here you can find more information.

Here you can find similar problem on SO, there are more solutions.

Community
  • 1
  • 1
Robert
  • 25,425
  • 8
  • 67
  • 81
3

You don't need to "to_char" the date first.

Either

select SYSDATE + 10/1440 from dual;

or

select to_char(SYSDATE + 10/1440,'dd-Mon-yyyy hh:mi:ss') from dual;

depending on whether you just want a date or a string representation of the date formatted in a certain way.

Colin 't Hart
  • 7,372
  • 3
  • 28
  • 51
  • 2
    I don't recommend `+ 10/1440`. Why not just use `+ INTERVAL '10' MINUTE`? – MatBailie Oct 15 '12 at 11:49
  • 1
    Very good point, shows how much some of us old timers are stuck in their ways... and using Postgresql at one place of work often makes me err on the side of "old fashioned" when going back to Oracle at the other... – Colin 't Hart Oct 15 '12 at 11:51