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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Updating date columns

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 taxenddate
1 2 NULL NULL
2 3 NULL NULL
3 6 NULL NULL
4 5 NULL NULL
5 9 NULL NULL
6 11 NULL NULL

Now i need to update taxstartdate,taxenddate by using follwing logic

If (‘CuttOffDay/CuttOffMonth/CurrentYear’ < CurrentDate) then
taxstartdate = ‘CuttOffDay/CuttOffMonth/CurrentYear’
EndDate = ‘CuttOffDay -1 /CuttOffMonth/CurrentYear + 1’
End If

If (‘CuttOffDay/CuttOffMonth/CurrentYear’ > CurrentDate) Then
taxstartdate = ‘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 taxenddate
1 2 1-2-2006 31-1-2007
2 3 2-3-2006 1-3-2007
3 6 3-6-2006 2-6-2007
4 5 4-5-2006 3-5-2007
5 9 6-9-2005 5-9-2006
6 11 5-11-2005 6-11-2006
1 11 31-10-2005 1-11-2006

note:all above dates are in the format of dd-mm-year



MEANS IF taxyearcutoffday IS 1 AND taxyearcutoffmonth IS 2 THEN CURRENT YEAR IS 2006 ,
taxstartdate, taxenddate SHOULD BE CALCULATED ACCORDING TO FIRST LOGIC


MEANS IF taxyearcutoffday IS 6 AND taxyearcutoffmonth IS 11 THEN CURRENT YEAR IS 2006 ,
taxstartdate, taxenddate SHOULD BE CALCULATED ACCORDING TO SECOND LOGIC


Please 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....
Go to Top of Page

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

Go to Top of Page
   

- Advertisement -