-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-now) 
select day(dateadd(d,-1,cast(ltrim(str(year(getdate())))+'-'+ltrim(str(month(getdate())))+'-1' as datetime)))
go
