Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Generate Two months dates

Author  Topic 

lols
Posting Yak Master

174 Posts

Posted - 2009-04-30 : 23:35:32
I want the simplest way to generate the dates of the last 2 months from today in the following manner:


1 May 2009
30 Apr 2009
29 Apr 2009
...
31 Mar 2009
29 Mar 2009
...
2 Mar 2009

Please tell me the query for this

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-04-30 : 23:40:06
is this u want
select convert(varchar(32),getdate()-number,106)
from master..spt_values
where type ='p' and number <=60
Go to Top of Page

lols
Posting Yak Master

174 Posts

Posted - 2009-05-01 : 00:20:28
Excellent Bklr! you Rock!!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-01 : 01:31:58
also see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519&SearchTerms=F_TABLE_DATE


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -