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. GetDate

GetDate

Scheduled Pinned Locked Moved Database
question
6 Posts 4 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
    berba
    wrote on last edited by
    #1

    Hi, When I run the following select getdate(), I'm getting the value below: 2011-07-04 13:54:22.427 I want to get only the value 2011-07-04... Can anybody advise? Note: I don't want to convert it to varchar. Cheers

    T S L 3 Replies Last reply
    0
    • B berba

      Hi, When I run the following select getdate(), I'm getting the value below: 2011-07-04 13:54:22.427 I want to get only the value 2011-07-04... Can anybody advise? Note: I don't want to convert it to varchar. Cheers

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      berba wrote:

      Note: I don't want to convert it to varchar.

      :doh: Try this Get Only DateTime Part without using Convert[^]

      thatraja


      **My Tip/Tricks
      My Dad had a Heart Attack on this day so don't...
      **

      1 Reply Last reply
      0
      • B berba

        Hi, When I run the following select getdate(), I'm getting the value below: 2011-07-04 13:54:22.427 I want to get only the value 2011-07-04... Can anybody advise? Note: I don't want to convert it to varchar. Cheers

        S Offline
        S Offline
        Simon_Whale
        wrote on last edited by
        #3

        If you are using SQL Server 2008 then use the date datatype

        select cast(getdate() as date)

        returns 2011-07-04

        Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

        B 1 Reply Last reply
        0
        • S Simon_Whale

          If you are using SQL Server 2008 then use the date datatype

          select cast(getdate() as date)

          returns 2011-07-04

          Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

          B Offline
          B Offline
          berba
          wrote on last edited by
          #4

          I'm using SQL2000

          S 1 Reply Last reply
          0
          • B berba

            I'm using SQL2000

            S Offline
            S Offline
            Simon_Whale
            wrote on last edited by
            #5

            Without using the convert function to manipulate the date then your best answer is from thatraja

            Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

            1 Reply Last reply
            0
            • B berba

              Hi, When I run the following select getdate(), I'm getting the value below: 2011-07-04 13:54:22.427 I want to get only the value 2011-07-04... Can anybody advise? Note: I don't want to convert it to varchar. Cheers

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              SELECT DATEADD(dd,0,DATEDIFF(dd,0,GETDATE())) does the trick.

              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