Thursday, August 28, 2008 5:45 PM
I am really, really new to PL/SQL having spent time on DB2/400 and MSSQL most of my career. I needed to manipulate time in Oracle and tried to apply existing knowledge with mixed results.
Craziness like having to select from table 'dual' instead of nixing the 'from' keyword like in T-SQL. Weird.
This site has helped a lot due its simple examples to help build my confidence. So anyway on to the title of the post... (sorry for the alignment of the code, first time pasting from Toad)
I am really curious why the creators of Oracle chose this particular syntax for manipulating time. It is not bad, just unexpected.
PL/SQL
select to_char(sysdate,'HH24') as "curhour",to_char(sysdate+1/24+1/24,'HH24') as "Twoplus" from dual
T/SQL
select datepart(hh,getdate()) as 'curhour', datepart(hh,dateadd(hh,2,getdate()))
It would be great if someone has a good site explaining the reasoning behind 1/24. If I missed something somewhere, please let me know a better way!
rusty