• I personaly cringe when I see manual calculations involving date/time. It's way to easy to mess up and there are usualy good library functions for it.

    In T-SQL would I for instance do something like this

    SELECT

    DATEPART(

    dd,

    DATEADD(

    dd,

    -1,

    DATEADD(

    mm,

    1,

    CONVERT(varchar(8), @Date, 20) + '01'

    )

    )

    ) AS [DaysInMonth]

    to get the numer of days in the current month. That way are you safe with all leap years and don't have to worry about a thing.