Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005
    Location
    Schaumburg, IL
    Posts
    28

    Unanswered: How to get Time in SmallDateTime?

    Hi,

    I just want to get the value from a smalldatetime into time only in a SQL Statement

    10/10/2005 10:00:00 AM --- > 10:00:00 AM

    What would be the best approached?


    Thanks,
    Vince

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    This will truncate all datetime values to Jan 1, 1900, leaving only the time portion. To format the resulting value, look up the CAST and CONVERT functions.
    Code:
    declare	@MyTime smalldatetime
    set	@MyTime = getdate()
    select	dateadd(d, -datediff(d, 0, @MyTime), @MyTime)
    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
  •