"hour" function?

  • I am continually amazed at the lack of functions within TSQL.  I like the product, but you would have thought that at this day and age of computer programming, the writers of TSQL would have put more functions in their product.

    They have a datatype which holds date and time, yet there is no function to easily separate out the two.  There is a day, month, and year function to work on datetime, but no time functions.

    so, my question is, after all this ranting, is there some special function somewhere to extract out the time, like "hour(getdate())"?, or do I need to use the convert/cast functions to edit out the hour?

    Thanks for any and all help.

    Russ....

  • have you looked at datepart()?

    select datepart(hh,getdate())

    DATEPART

    Returns an integer representing the specified datepart of the specified date.

    Syntax

    DATEPART ( datepart , date )

    Arguments

    datepart

    Is the parameter that specifies the part of the date to return. The table lists dateparts and abbreviations recognized by Microsoft® SQL Server™.

    DatepartAbbreviations
    yearyy, yyyy
    quarterqq, q
    monthmm, m
    dayofyeardy, y
    daydd, d
    weekwk, ww
    weekdaydw
    hourhh
    minutemi, n
    secondss, s
    millisecondms
  • I feel like an idiot and I must be going blind.

     

    Thanks

    Russ...

  • If your not going blind, then your not doing it right.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply