How will you find out the last day of the current month?
select dateadd(month,datediff(month,0,getdate())+1,-1)
The logic is to find out number of months from base date (1900, jan 01) and add 1 the result to base date itself and subtract one day.
Read More..   [0 clicks]
Published under: SQL Server Interview Questions · · · ·