If i'm given a date (say @d = '11-25-2010'), how can I determine the end of the quarter from that date. I'd like to use a timestamp one second before midnight.
I can get this:
select dateadd(qq, datediff(qq, 0, getdate()), 0) as quarterStart
which gives me: '10-1-2010'
and I use this for one second before midnight of a given day:
select DateAdd(second, -1, DateAdd(day, DateDiff(day, 0, @d))+1, 0) ) AS DayEnd
in the end, a quarterEnd method would give me '12-31-2010 23:59:00'