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. How to seperate Date and Time in SQL

How to seperate Date and Time in SQL

Scheduled Pinned Locked Moved Database
databasetutorial
6 Posts 5 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.
  • C Offline
    C Offline
    ChennaiBabu
    wrote on last edited by
    #1

    Hi All, Greetings...i have a doubt...i've to separate date and time in sql table..its displaying both date and time...can any one tell me the query for that... Thanks in Advance

    Babu

    W A K 3 Replies Last reply
    0
    • C ChennaiBabu

      Hi All, Greetings...i have a doubt...i've to separate date and time in sql table..its displaying both date and time...can any one tell me the query for that... Thanks in Advance

      Babu

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

      select datepart(year,timestamp) + '/' + datepart(month,timestamp) + "'/' + datepart(day,timestamp) as date,datepart(hour,timestamp) + ':' + datepart(minute,timestamp) + ':' + datepart(second,timestamp) as time from sometable Fairly simple using the datepart function. Be adviced: The result is a string but you can convert it back to a datetime type.

      WM.
      What about weapons of mass-construction?

      1 Reply Last reply
      0
      • C ChennaiBabu

        Hi All, Greetings...i have a doubt...i've to separate date and time in sql table..its displaying both date and time...can any one tell me the query for that... Thanks in Advance

        Babu

        A Offline
        A Offline
        albCode
        wrote on last edited by
        #3

        this SQL code takes current date and time of ur PC select substring(cast(getdate()as varchar),1,11) as datte, substring(cast(getdate()as varchar),14,8) as ttime

        J 1 Reply Last reply
        0
        • C ChennaiBabu

          Hi All, Greetings...i have a doubt...i've to separate date and time in sql table..its displaying both date and time...can any one tell me the query for that... Thanks in Advance

          Babu

          K Offline
          K Offline
          KeesVer
          wrote on last edited by
          #4

          select cast(cast(getdate() as int) as datetime) as DateVal, getdate()-cast(getdate() as int) as TimeVal

          1 Reply Last reply
          0
          • A albCode

            this SQL code takes current date and time of ur PC select substring(cast(getdate()as varchar),1,11) as datte, substring(cast(getdate()as varchar),14,8) as ttime

            J Offline
            J Offline
            Jayamaruthia
            wrote on last edited by
            #5

            Thnaks it is useful for me

            Regards, Jayamaruthi.A

            A 1 Reply Last reply
            0
            • J Jayamaruthia

              Thnaks it is useful for me

              Regards, Jayamaruthi.A

              A Offline
              A Offline
              albCode
              wrote on last edited by
              #6

              You are welcome...

              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