Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2003
    Location
    Montreal
    Posts
    38

    Question Unanswered: Trimming a DateTime

    Hi,

    Probably easy but I'd like the best way to do it:

    I have a datetime column with A LOT of rows. I'd like a select statement to return each date with everything after the hour part set to zero.

    For example, if my column has the following values:

    2004-11-03 13:03:36.876
    1999-02-17 01:56:12.126

    Should return:

    2004-11-03 13:00:00.000
    1999-02-17 01:00:00.000

    I know I can do this with a function and a couple of casts but there must be an easier (and faster) way!?!?

    Thanks,

    Skip.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Convert(char(13), YourValue, 120)+':00:00.000'
    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
  •