Author |
Topic  |
|
quince
Junior Member
 
Canada
103 Posts |
Posted - 06 May 2007 : 17:07:46
|
I am working on a system where i need to count only the working days from the day i enter a ticket in my system and the number of dates depeneds on the entry i select.
i try this code and i kno it's a mess but i need your help, i need to submit it tomorrow <% sla = 20
w=date()
for i =1 to sla w= DateAdd("d",i,date())
if weekdayName(weekday(w)) = weekdayName(6) or weekdayName(weekday(w)) = weekdayName(7) then
fsla = sla +2
end if
lastdat = dateadd("d",fsla,date()) if weekdayName(weekday(lastdat)) = weekdayName(6) or weekdayName(weekday(lastdat)) = weekdayName(7) then
lastdat = lastdat + 2
end if
next
%>
thanks in advance,
Best Regards, quince |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 06 May 2007 : 20:53:44
|
Is there a particular problem with that code? Errors? Unexpected results? A little more information would help. |
 |
|
quince
Junior Member
 
Canada
103 Posts |
Posted - 06 May 2007 : 23:35:27
|
yes, some time the result will be more by 2 and some times it will be less by 2,
for example, if sla = 20 i must get 4/6/2007 i am getting 6/6/2007 |
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 07 May 2007 : 12:27:40
|
Looks like you're adding 2 for both Sat. and Sun. which is giving you the extra 2 days... at least that's what I think is happening when I look through your code. Have you tried either manually working it out on paper following the logic or outputting the value of all the variables at each major point in the code? |
 |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 07 May 2007 : 13:16:59
|
This is probably an excellent candidate for flowcharting!
But fsla = sla +2 is going set fsla to 22 several times over (if you have multiple weekends). I think you need to clear up the logic here, break reexamine the problem, you might find it has a simpler solution |
 |
|
quince
Junior Member
 
Canada
103 Posts |
Posted - 07 May 2007 : 23:15:58
|
still i am unable to solve it i tried another code, that code wil count how many friday and saterday, then itwill add them to with the sla to todays date, after that it will check if the lastdate will come on friday or staterday (weekend) it will add 2. within the same month it is working, but if it is between two monthes it is not working, i think i need to do some think with months end with 31 and Feb.
|
 |
|
|
Topic  |
|