Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    164

    Unanswered: Convert Smalldatetime

    Hello everyone. I am running into some small problems converting a smalldatetime field. I currently have 2005-10-17 00:00:00
    in the field but what it to have forward slashes instead of th dash. I tried a few convert methods but not successful.

    Does anyone have any ideas on how to make this work?

    All help is appreciated.

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by estefex
    Hello everyone. I am running into some small problems converting a smalldatetime field. I currently have 2005-10-17 00:00:00
    in the field but what it to have forward slashes instead of th dash. I tried a few convert methods but not successful.

    Does anyone have any ideas on how to make this work?

    All help is appreciated.

    Try convert(varchar(10), getdate(), 111)

    Regards,

    hmscott
    Have you hugged your backup today?

  3. #3
    Join Date
    Jan 2004
    Posts
    164
    Quote Originally Posted by hmscott
    Try convert(varchar(10), getdate(), 111)

    Regards,

    hmscott
    Thanks Again. I worked just fine.

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    WHY....do you want to conver the datetime value in the first place? Or are you just trying to truncate off the time portion, in which case this method is faster if less intuitive:
    select dateadd(day, datediff(day, 0, getdate()), 0)
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •