Dear all
I ve been asked to do find a way to calculate all weeks in a year.
More specifically working weeks, which doesnt mean that i have to exlude any days like weekends but simply it means that the first week it will be: 14-March-2002 to 20-March-2002 starting from Thursday to Wednesday. So all these working weeks will count standart Thursday to the following Wednesday.
And as that the last working week it will be:
6-Mar-2003 to 12-Mar-2003
In total we have 52 working weeks.
Al i wanted was a similar script that given a Date will display a number (from 1-52) that shows in which working week we are.
So for example if i give 14-Mar-2002 the script will return 1.
and also if i give 17-Mar-2002 the script will again return 1. While giving 12-Mar-2003 the script will return 52.
The problem is that i did that using ASP script which goes through every single week and validate it as follows:
if (days>=14) and (days<=20) AND (months="Mar"
AND (years="2002"
THEN : i = 1 : end if
if (days>=21) and (days<=27) AND (months="Mar"
AND (years="2002"
THEN : i = 2 : end if
if ((days>=28) and (months="Mar"
) OR ((days<=3) and (months="Apr"
) AND (years="2002"
THEN : i = 3 : end if Rem***month changes
.......
if ((days>=26) and (months="Dec"
and (years="2002"
) OR ((days<=1) and (months="Jan"
and (years="2003"
) THEN : i = 42 : end if rem year changes
.......
if (days>=6) and (days<=12) AND (months="Mar"
AND (years="2003"
THEN : i = 52 : end if
This done on ASP and works fine. But the problem is that only works for hardcoded dates as you see. E.g cannot work for year 2005 cause i havent put anything for this.
So i was about a Js or VB script that can do something similar but more dinamiclly. Any thoughts?
I ve been asked to do find a way to calculate all weeks in a year.
More specifically working weeks, which doesnt mean that i have to exlude any days like weekends but simply it means that the first week it will be: 14-March-2002 to 20-March-2002 starting from Thursday to Wednesday. So all these working weeks will count standart Thursday to the following Wednesday.
And as that the last working week it will be:
6-Mar-2003 to 12-Mar-2003
In total we have 52 working weeks.
Al i wanted was a similar script that given a Date will display a number (from 1-52) that shows in which working week we are.
So for example if i give 14-Mar-2002 the script will return 1.
and also if i give 17-Mar-2002 the script will again return 1. While giving 12-Mar-2003 the script will return 52.
The problem is that i did that using ASP script which goes through every single week and validate it as follows:
if (days>=14) and (days<=20) AND (months="Mar"
if (days>=21) and (days<=27) AND (months="Mar"
if ((days>=28) and (months="Mar"
.......
if ((days>=26) and (months="Dec"
.......
if (days>=6) and (days<=12) AND (months="Mar"
This done on ASP and works fine. But the problem is that only works for hardcoded dates as you see. E.g cannot work for year 2005 cause i havent put anything for this.
So i was about a Js or VB script that can do something similar but more dinamiclly. Any thoughts?