 |
| ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 16th, 2003, 10:29 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Calculating the Tax week (UK)
Hi All,
Does anyone have any code to calculate what the current tax week is? This refers to the UK tax week.
Many thanks,
Treadmill
|
|

June 16th, 2003, 06:51 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What defines a UK tax week.
regards
David Cameron
|
|

June 17th, 2003, 02:08 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi David,
The tax year begins on 6th April 2003 in the UK. Does this help in working out the tax week?
Regards,
Treadmill
|
|

June 17th, 2003, 02:29 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Not entirely, but I found a site with some php code to calculate the UK tax week that told me how the date is calculated. The function below will return the date that is the starting day of the tax week for the date you pass in as a parameter. You could get rid of the DayDif variable but the code would be a bit harder to read.
Code:
Function GetTaxWeekStartDay(ByVal curDate)
Dim YearStart
Dim DayDif
If Not IsDate(curDate) Then Exit Function
' get the start of the current tax year
YearStart = CDate(Year(curDate) & "-04-06")
If (YearStart > curDate) Then YearStart = DateAdd("d", -1, YearStart)
DayDif = DateDiff("d", YearStart, curDate)
GetTaxWeekStartDay = DateAdd("d", -1 * (DayDif Mod 7), curDate)
End Function
regards
David Cameron
|
|

June 17th, 2003, 03:23 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try this function
Code:
Function GetTaxWeek(datDate)
Dim datStartDate
Dim bytTaxWeek
'Make sure the passed in variable is a date
If IsDate(datDate) Then
'Get the 6th April on the year of the passed in date
datStartDate = DateSerial(Year(datDate), 4, 6)
'If the passed in date is before the 6th April then go back a year
If datDate < datStartDate Then datStartDate = DateAdd("yyyy", -1, datStartDate)
'Get the next Monday
Do Until UCase(WeekDayName(WeekDay(datStartDate))) = "MONDAY"
datStartDate = DateAdd("d", 1, datStartDate)
Loop
'The tax week is the number of days between the 2 dates divided by 7 plus 1
bytTaxWeek = Int(DateDiff("d", datStartDate, datDate) / 7) + 1
'If this is 0 then we are still in the previous tax year
If bytTaxWeek = 0 Then bytTaxWeek = 52
End If
GetTaxWeek = bytTaxWeek
End Function
You pass in the date you want to get the tax week for and it will return the tax week (obvious really :))
I hope this is what you were after.
Regards
Owain Williams
|
|

June 17th, 2003, 07:22 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I just realised that there was an error in the function I posted. The line:
Code:
If (YearStart > curDate) Then YearStart = DateAdd("d", -1, YearStart)
should read
Code:
If (YearStart > curDate) Then YearStart = DateAdd("yyyy", -1, YearStart)
Actually I think that Owain's function is closer to what you want.
regards
David Cameron
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Tax |
RaCheer |
ASP.NET 1.0 and 1.1 Basics |
2 |
February 3rd, 2006 03:44 PM |
| Sales Tax |
RaCheer |
ASP.NET 1.0 and 1.1 Basics |
5 |
January 31st, 2006 10:54 AM |
| TAX / VAT Calucating DB |
crmpicco |
MySQL |
6 |
September 12th, 2005 10:09 AM |
| TAX Calculation |
crmpicco |
Classic ASP Databases |
0 |
June 8th, 2005 05:42 AM |
|
 |