Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. adding the time component of two dates

adding the time component of two dates

Scheduled Pinned Locked Moved Database
oracletutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    balaji t
    wrote on last edited by
    #1

    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

    W 1 Reply Last reply
    0
    • B balaji t

      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

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      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:09

      Notice that when using only time portion in to_date function, the date is set to the first day of current month. Mika

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups