Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

select the last month in SQL server 2005 Expand / Collapse
Author
Message
Posted Monday, December 14, 2009 5:49 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Today @ 1:11 AM
Points: 784, Visits: 633
DECLARE @year VARCHAR(10)

SELECT @year = '2009'

SELECT
LEFT(CONVERT(VARCHAR,DATEADD(MM,number,@year),112),4)+' '+ LEFT(DATENAME(MM,DATEADD(MM,number,@year)),3)
FROM
Master..spt_Values
WHERE
Type = 'p' AND

number < DATEPART(MM,GETDATE())-1


Regards,
Mitesh OSwal
+918698619998
Post #833750
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse