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 or Substracting time spans from a DateTime SQL value

Adding or Substracting time spans from a DateTime SQL value

Scheduled Pinned Locked Moved Database
questiondatabasetutorial
3 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.
  • D Offline
    D Offline
    Den2Fly
    wrote on last edited by
    #1

    Hello every buddy, How can I add for example some minutes to a datetime type value and get result again as a datetime? Thank you so much, - Den --- "Art happens when you least expect it."

    C 1 Reply Last reply
    0
    • D Den2Fly

      Hello every buddy, How can I add for example some minutes to a datetime type value and get result again as a datetime? Thank you so much, - Den --- "Art happens when you least expect it."

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      This example takes the current time and adds 5 minutes to it: DATEADD(minute, 5, getdate()) The first arg is the date part (minute, hour, year, month, etc.) The second arg is the amount you want to add (or for negative values, subtract) The third argument is the source datetime.


      Do you want to know more?

      D 1 Reply Last reply
      0
      • C Colin Angus Mackay

        This example takes the current time and adds 5 minutes to it: DATEADD(minute, 5, getdate()) The first arg is the date part (minute, hour, year, month, etc.) The second arg is the amount you want to add (or for negative values, subtract) The third argument is the source datetime.


        Do you want to know more?

        D Offline
        D Offline
        Den2Fly
        wrote on last edited by
        #3

        All I can do to appreciate now is to say thanks :-) --- "Art happens when you least expect it."

        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