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)
 datetime function in stored procedures

Author  Topic 

nonkubhengu
Starting Member

1 Post

Posted - 2009-10-09 : 07:37:40
Hi all

i need to retrieve data from a sql server 2005 database based on the captured date.the data will be used in a creating a report. the use will select the month and year they want the report for.

please help me out!

Nonku Bhengu

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-09 : 07:44:40
where month(capturedDate) = @given_month and year(capturedDate) = @given_year


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-10-09 : 08:11:36
where captureddate >= dateadd(month,@given_month-1,dateadd(yy,@given_year-1900,0))
and captureddate < dateadd(month,@given_month,dateadd(yy,@given_year-1900,0))

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -