I think SQL does a pretty good job with dates. Here is a very simple way to get the last day of any month. The example retreaves the last day of the last month.
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))
Replace the GETDATE() with whatever date you need to find the last day of the month before.
Recent Comments