SQL date formating

Discussion in 'Software' started by be0, Nov 16, 2007.

  1. be0

    be0 Corporal

    Hello everyone,

    I am very upset with this datetime field. I would like to to the following:

    where
    ship_date = getdate()

    I cant do this because getdate returns 2007-11-16 11:47:09.690
    I only want 2007-11-16 part not the time. So no rows get returned. How do I edit this so that I only get the date in there?

    Thanks for the help!!!!
     
  2. timduk

    timduk Private E-2

    If ship_date is a datetime, then :

    where year( ship_date ) = year( getdate() )
    and month( ship_date ) = month( getdate() )
    and day( ship_date ) = day( getdate() )

    might do it.

    It has been a while since I did any SQL, and never on SQL-Server, so maybe wrong!
     
  3. Wookie

    Wookie Sergeant Major

  4. Publius

    Publius Sergeant


MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds