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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-03-29 : 08:46:15
|
| Cindy writes "Hi:I am trying to automate a query and need help writing a case statement. I have a declare statement which declares the begin and end date which are hard coded as '02/01/2006' and '02/28/2006' on my query below. I need to find a way for my query to look back at the date range (@BEGDATE and @ENDDATE) and populate the month. I am spinning my wheels trying to figure out how to do this. I hope my question makes sense. You input is greatly appreciated!select doctext, doccode, doccatcd, docsubcd, [Month] = case when docdate between '02/01/2006' and '02/28/2006' then 'February'From CSRREPORTING..CSSDLOGF01 with (NOLOCK)Where DOCDATE BETWEEN '02/01/2006' and '02/28/2006' --@BEGDATE AND @ENDDATEAnd doccode > 0" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-29 : 08:50:52
|
| Use DateName(month,yourDate)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|