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 |
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-06-17 : 09:59:05
|
| I have a SP that I want to use just the Month and Year as parameter and then default the end of month date base on the year and month. Anyone know how I would go about doing this. We have posting dates that I want to use as my search criteria and those are posted by month end.Example:Month end is 1/31/2005, the parameter I set is "1" for Month and then "2005" for Year. Then default Day to month end date so that the user does not need to enter it. Here's my query:CREATE PROCEDURE CW_MONTHEND_REPORT@DATE AS SMALLDATETIMEASSELECT ID, POSTING_DATE, CLOSING_DATEFROM WORK_IN_PROCESSWHERE POSTING_DATE = @DATEHere's an attempt, but I don't know how to set my @DAY parameter to default to month end base on year and month.CREATE PROCEDURE CW_MONTHEND_REPORT@MONTH AS VARCHAR(2),@DAY AS VARCHAR(2),@YEAR AS VARCHAR(4)ASSELECT ID, POSTING_DATE, CLOSING_DATEFROM WORK_IN_PROCESSWHERE POSTING_DATE = @MONTH + '/' + @DAY + '/' + @YEAR |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
chriskhan2000
Aged Yak Warrior
544 Posts |
Posted - 2005-06-17 : 10:21:54
|
| Thanks I got it to work now.I just set the date for Month and Year as parameter with the Date format.Example:CREATE PROCEDURE CW_MONTHEND_REPORT@MONTH AS VARCHAR(2),@YEAR AS VARCHAR(4)ASSELECT ID, POSTING_DATE, CLOSING_DATEFROM WORK_IN_PROCESSWHERE DATENAME(MONTH, POSTING_DATE) = @MONTHAND YEAR(POSTING_DATE) = @YEAR |
 |
|
|
|
|
|