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
 Analysis Server and Reporting Services (2005)
 Month and year parameter

Author  Topic 

1sabine8
Posting Yak Master

130 Posts

Posted - 2009-07-02 : 09:29:05
Hi,
I need to build a report with 2 parameters: month and year
Then i will get the data where the dates are included in the chosen month and year.
How is it feasible?
Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-02 : 09:41:32
[code]DECLARE @Year SMALLINT,
@Month TINYINT

SELECT @Year = 2008,
@Month = 2

DECLARE @FromDate DATETIME,
@ToDate DATETIME

SELECT @FromDate = DATEADD(MONTH, 12 * @Year - 22801 + @Month, 0),
@ToDate = DATEADD(MONTH, 12 * @Year - 22800 + @Month, 0)

SELECT *
FROM Table1
WHERE Col1 >= @FromDate
AND Col1 < @ToDate[/code]


Microsoft SQL Server MVP

N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -