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 |
|
Swati Jain
Posting Yak Master
139 Posts |
Posted - 2006-07-07 : 01:34:57
|
| Hi Experts,I am facing some problem in my project.I have four columns.CuttOffDay CuttOffMonth taxstartdate taxenddate1 2 NULL NULL2 3 NULL NULL3 6 NULL NULL4 5 NULL NULL5 9 NULL NULL6 11 NULL NULLNow i need to update taxstartdate,taxenddate by using follwing logicIf (‘CuttOffDay/CuttOffMonth/CurrentYear’ < CurrentDate) thentaxstartdate = ‘CuttOffDay/CuttOffMonth/CurrentYear’EndDate = ‘CuttOffDay -1 /CuttOffMonth/CurrentYear + 1’End IfIf (‘CuttOffDay/CuttOffMonth/CurrentYear’ > CurrentDate) Thentaxstartdate = ‘CuttOffDay + 1/CuttOffMonth/CurrentYear - 1’taxenddate = ‘CuttOffDay/CuttOffMonth/CurrentYear’but we don't have year column.Assuming year is current year,2006.At last result should be CuttOffDay CuttOffMonth taxstartdate taxenddate1 2 1-2-2006 31-1-20072 3 2-3-2006 1-3-20073 6 3-6-2006 2-6-20074 5 4-5-2006 3-5-20075 9 6-9-2005 5-9-20066 11 5-11-2005 6-11-20061 11 31-10-2005 1-11-2006note:all above dates are in the format of dd-mm-yearMEANS IF taxyearcutoffday IS 1 AND taxyearcutoffmonth IS 2 THEN CURRENT YEAR IS 2006 ,taxstartdate, taxenddate SHOULD BE CALCULATED ACCORDING TO FIRST LOGICMEANS IF taxyearcutoffday IS 6 AND taxyearcutoffmonth IS 11 THEN CURRENT YEAR IS 2006 ,taxstartdate, taxenddate SHOULD BE CALCULATED ACCORDING TO SECOND LOGICPlease help me. |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-07-07 : 01:45:08
|
| Why don't you have a shot at doing it yourself, then possibly posting here if you get stuck. I think people would be more open to helping if you've at least had a shot at it. Try breaking down the task into smaller components and tackling them separately. You'll learn a lot more this way compared to someone just giving you the answer.... |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-07 : 02:53:59
|
Take a look at CASE . . . WHEN . . . END in the Books OnLine.Post back if you still have problem KH |
 |
|
|
|
|
|