Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2003
    Posts
    163

    Question Unanswered: Urgent: A simple question about the most asked topic - DATE

    Hi,

    The subject say it all

    I have a field which stores date which the datetime datatype... The problem is that I am also getting time information in this stored field.

    I just want to extract the date part in dd-Mmm-yy format (e.g. 07-May-04). I tried convert (char (8), MyDateField, 112) but it gives me date in yyyymmdd format. How do I get the results in dd-Mmm-yy format instead?

    Thanks.

  2. #2
    Join Date
    Feb 2004
    Location
    Poland
    Posts
    96
    SELECT DATENAME(DAY,koniec) + ' ' + DATENAME(MONTH,koniec) + ' ' + DATENAME(YEAR, koniec) from koniec

  3. #3
    Join Date
    Jan 2003
    Location
    India
    Posts
    523
    select convert(varchar,getdate(),106)

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Formats 120 and 121 are unambiguously interpreted by SQL Server, varchar is not necessary as the resulting string is always the same length:

    select convert(char(10),getdate(),120)

    -or- (for you, Brett!)

    select convert(varchar,getdate(),121)
    If it's not practically useful, then it's practically useless.

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

  5. #5
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I didn't know it was beat on brett day...

    But hey, I'm game...


    dog pile on the rabbit...

    dog pile on the rabbit...

    dog pile on the rabbit...

    dog pile on the rabbit...

    ahh, the good old days...

    betcha don't know where that's from...

    and yes they are always the same length...and by using varchar, you incur extra un-needed overhead...

    but you know what...

    It's FRIDAY damn it....(but it's not 5:00 yet )
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    I was just tipping my hat to you, Brett.

    It's not beat on Brett day. It's Margarita day, right?
    If it's not practically useful, then it's practically useless.

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

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    EVERY Day is margarita day!

    No, I was refering to the fact that I use varchar for every g-d damn thing...except tables def's under 15 chars...

    And your point was valid...the date conversion for SOME formats (The ones WE always use) is fixed...

    Who the hell uses "May 7, 2004"

    ?????????
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  8. #8
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by Brett Kaiser
    betcha don't know where that's from...
    The correct spelling is "Dog pile on da wabbit" if you are picky about those things!

    -PatP

Posting Permissions

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