adding the time component of two dates
-
hi folks,. Can any1 let me know how to sum the time component of two time values in oracle? for e.g s = 09:00 t = 19:09 i want to add s and t
T.Balaji
Hi, There are two questions concerning this: - what about the date portion. Should the start date be current date (in your example the result goes to next date) - what are the datatypes for time components, dates, strings? This SELECT should give you some starting point to adding elements to a date. This returns first day of this month reflected to desired time (variable s) and then added with given time (variable t) and the result is formatted to string to see all the elements:
SELECT TO_CHAR( SYSDATE,
'dd.mm.yyyy hh24:mi:ss'
) AS CurrentTime,
TO_CHAR( TO_DATE('09:00','hh24:mi') -- results in first day of this month at 09:00
+ INTERVAL '19' HOUR -- adding hours
+ INTERVAL '09' MINUTE, -- adding minutes
'dd.mm.yyyy hh24:mi:ss' -- formatting
) AS AddedTime
FROM dual;And the result:
CURRENTTIME ADDEDTIME
6.8.2008 21:18 2.8.2008 4:09Notice that when using only time portion in to_date function, the date is set to the first day of current month. Mika