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. date part of getdate

date part of getdate

Scheduled Pinned Locked Moved Database
databasequestion
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.
  • G Offline
    G Offline
    Goodway
    wrote on last edited by
    #1

    i want to use the date part of the function getdate in my sql query. the getdate function return the current date and time. i want only the date part. how can i do it.

    M 1 Reply Last reply
    0
    • G Goodway

      i want to use the date part of the function getdate in my sql query. the getdate function return the current date and time. i want only the date part. how can i do it.

      M Offline
      M Offline
      M Peer
      wrote on last edited by
      #2

      Goodway, First of all I assume you use SQL Server (7.0/2000). If not quit reading. Then, SQL Servers date/time datatype always consists of a date AND a time part. A date without a time component does not exsist is SQL Server. If you insert a date value without a time, for example jan 1, 2004, SQL Server inserts the date as 2004/01/01 00:00:00.000 (for smalldatetime skip the milliseconds). So if you need a date without a time you need to convert a datetime value to a string. You can use the CONVERT-function in SQL (see "CAST and CONVERT" in SQL Books online). Example: SELECT CONVERT (varchar(24), GetDate() , 103); Returns: 01/01/2004 -- Note: the result is a string. Not a datetime value. Good luck

      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