sql server - Get the last day of the month in SQL -
I have to meet in the form of a date in SQL, on the last day of the month. If I have the first day of the month, then I can do something like this:
DATEADD (DAY, DATEADD (MONTH, '2009-05-01', 1), -1) < / Code>
But does anyone know how it is normalized, can I get any date for the last day of the month?
This is my version; No string manipulation or casting is necessary, only one to each DATEADD
, YEAR
and MONTH
function:
announcement @ test date set @ test = gate-date () - or Select another date DATEADD (month, ((year (TTES) - 1900) * 12) + month (@ test), -1)
Comments
Post a Comment