Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011
    Posts
    78

    Unanswered: Use Select to get the hour only

    Is there a number to get the hour only? Please help, thank you

    108 is for hour_minute_second
    101 is for Date


    Example: the time is 09:23:26

    I only want the 09, which is the hour.

    SELECT
    CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond,
    CONVERT(VARCHAR(8),GETDATE(),101) AS DateOnly
    GO

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    SELECT DatePart(hh, GetDate())
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jul 2011
    Posts
    78
    Thank you, I figure it out.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    hey mangolili, how many different threads for the same darned query are you gonna start?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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