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.
| Author |
Topic |
|
Fathima
Starting Member
1 Post |
Posted - 2008-04-02 : 23:59:40
|
| hai friends, I have a problem in finding month and year sequence between to date. one date is minimum date for example march 2005 and one maximum date is today's date april 2008. I need output of month between these years like thisMarch 2005April 2005May 2005......January 2006...December 2007 January 2008.....April 2008 Can any one help me to develop a stored procedure to produce this output...Thanks in advance,Abilina |
|
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2008-04-03 : 01:31:36
|
| CREATE PROCEDURE PRINTDATE@StartDate DATETIME,@EndDate DATETIMEASWHILE @StartDate<=@EndDateBEGINPRINT datename(mm,@StartDate) + '-'+datename(yy,@StartDate)SET @StartDate=DATEADD(month,1,@StartDate)ENDPrakash.PThe secret to creativity is knowing how to hide your sources! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-03 : 01:49:28
|
| [code]SELECT DATENAME(mm,DATEADD(mm,number,@StartDate)) + ' ' + DATENAME(yy,DATEADD(mm,number,@StartDate))FROM master..spt_valuesWHERE type='p' AND number BETWEEN 0 AND DATEDIFF(mm,@StartDate,@EndDate)[/code]where @StartDate AND @EndDate are your two dates |
 |
|
|
|
|
|
|
|