T-SQL Tutorial

How to get last date of month in sql


To get last date of month uses sql server date function and EOMONTH function.

Syntax

EOMONTH ( start_date [, month_to_add ] )





Examples

SELECT EOMONTH (GETDATE());

SELECT EOMONTH (SYSDATETIME());

SELECT EOMONTH (CURRENT_TIMESTAMP);

SELECT EOMONTH (SYSDATETIMEOFFSET());