Skip to content
Advertisement

Month Name and Last date of each month for previous 3 months in sql

I’m analyzing customer transactions for the previous 3 months, excluding the current month, I would like to get the month names of the previous 3 months and the last date of each of the 3 months.

—output

—expected

Advertisement

Answer

You can use SQL Server EOMONTH() function to compute the last day of a month.

Consider:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement