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 |
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2011-09-20 : 14:01:18
|
| I am trying to retreive all of last months records from a table. I have a column called "rDate" which is a char(6). Values in this column look like "01SP11", "02SP11", "03SP11", etc....pseudo code:select * from myTablewhere month(rDate) = getDate() - one MonthAny suggestions? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-20 : 22:08:09
|
| what kind of date format is this? so how will you represent January,February etc?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2011-09-21 : 08:44:02
|
| Guess I am looking to convert JA = 01, FB = 02, MR = 03, etc...And then compare rDate = presentDate - one month. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-21 : 08:46:18
|
| then best way is to have mapping table for that otherwise you will end up putting lots of case when constructs------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2011-09-21 : 11:50:59
|
| Mapped table worked like a champ!Thanks for the suggestion. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-21 : 11:52:46
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|