Results 1 to 12 of 12

Thread: Time

  1. #1
    Join Date
    Nov 2005
    Location
    Jersey
    Posts
    47

    Unanswered: Time

    Hi all.

    Does anyone know how to take the Time piece out of a DateTime field? I tried datepart but then I have to put it back together and the other problem with that is that it doesn't give me hh:mm:ss format. I get h:m:s format.


    Please help.

    Thanks,
    ODaniels

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Look up CONVERT in BOL
    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.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    ...and while you are at it, lookup the DATETIME datatype as well. You seem to be confused about what it represents and how it is stored. It does not have any innate "format".
    If it's not practically useful, then it's practically useless.

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

  4. #4
    Join Date
    Nov 2005
    Location
    Jersey
    Posts
    47
    I'm pretty sure I'm not confused about what my users what displayed. They want the time portion only of the datetime field. I looked up convert and datetime and don't see any way to just get the time. So I wrote a little UDF to pull it out.

    Thank you all for your help anyway.

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    SELECT Convert(CHAR(8), GetDate(), 108)
    -PatP

  6. #6
    Join Date
    Nov 2005
    Location
    Jersey
    Posts
    47
    Thank you PatP. You are amazing.

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Quote Originally Posted by Pat Phelan
    Code:
    SELECT Convert(CHAR(8), GetDate(), 108)
    -PatP
    That?! That code was "amazing"? I have some glass beads I'd be willing to trade for your property if you are interested. (I say this only because I know it will be several days before Pat has a chance to get back at me...)
    If it's not practically useful, then it's practically useless.

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

  8. #8
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by blindman
    (I say this only because I know it will be several days before Pat has a chance to get back at me...)
    Says who? I'm still over two hours from going down for the count! Heck, I'm still hanging at the orifice for a bit longer.

    -PatP

  9. #9
    Join Date
    Nov 2005
    Location
    Jersey
    Posts
    47
    I didn't say the code was amazing (although it was a huge help). I said PatP was amazing.

    And trust me, you don't want my property. :-)

  10. #10
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Well, Pat is amazing. You should see his good stuff.
    If it's not practically useful, then it's practically useless.

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

  11. #11
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by blindman
    Well, Pat is amazing. You should see his good stuff.
    http://www.sqlteam.com/forums/topic....12&whichpage=3

    It is frivolous but so am I and Pat has a love of frivolity so I think it counts.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  12. #12
    Join Date
    Nov 2005
    Location
    Jersey
    Posts
    47
    wow. Pat's even more amazing then I thought.

Posting Permissions

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