Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Manipulate with date and working days
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

quince
Junior Member

Canada
103 Posts

Posted - 06 May 2007 :  17:07:46  Show Profile
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  Show Profile  Visit AnonJr's Homepage
Is there a particular problem with that code? Errors? Unexpected results? A little more information would help.
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 06 May 2007 :  23:35:27  Show Profile
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
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 07 May 2007 :  12:27:40  Show Profile  Visit AnonJr's Homepage
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?
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 07 May 2007 :  13:16:59  Show Profile  Send pdrg a Yahoo! Message
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
Go to Top of Page

quince
Junior Member

Canada
103 Posts

Posted - 07 May 2007 :  23:15:58  Show Profile
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.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.26 seconds. Powered By: Snitz Forums 2000 Version 3.4.07