April 17, 2006 at 1:11 pm
I am trying to write a query to find the last day of the previous month.
April 17, 2006 at 2:01 pm
Substitute the date you have for getdate()
select
dateadd(d,-1,convert(datetime,convert(varchar(2),datepart(mm,getdate())) + '/01/' +
convert(varchar(4),datepart(yy,getdate()))))
April 17, 2006 at 2:01 pm
Select
DateAdd(dd,-1,Convert(datetime,Convert(varchar(4),Year(GetDate())) + '-' + Convert(varchar(4),Month(GetDate())) + '-01'))
April 17, 2006 at 9:29 pm
Short, simple, nasty fast because there are no VARCHAR conversions...
SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)-1
--Jeff Moden
Change is inevitable... Change for the better is not.
April 18, 2006 at 9:51 am
Very nice! That's so slick!
April 18, 2006 at 10:49 am
Same result with time..
select getdate() - datepart(day,getdate())
April 18, 2006 at 1:24 pm
Thanks Much all..
Kavita
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply