Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to put Year Parameters in SQL Server 2005 Database

Status
Not open for further replies.

satyakumar

Programmer
Jun 29, 2008
44
US
Hi Friends,

I am running a custom SQL in SQL Server, Where i need some help in giving parameters to the SQL.

Basically users want to give parameters of Year and Month.

Suppose if users has given 2011 july , then i should generate the data for the months of:

31-Dec 2009, 31-Dec 2010, 31-July 2011.

Always we have to show last day of the previous years.

Another Example:

If Users has given 2011 Dec.
then we have to show.

31-Dec 2009, 31-Dec 2010, 31-Dec 2011.

Please let me know how to write the SQL parameter Statement to generate the data.



 
Without any code to reference...

Code:
 DECLARE @Month TINYINT;
...
WHERE MONTH(FieldDate) = @Month

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top