Hi All,
I want to add the weekend date with condition and have a Holiday table.
I came up this code with modified this
http://www.codeproject.com/Articles/...-Holidays-Week and Working With Business Dates (Business Holidays/Weekends, Etc) By glitch177k, 9 Dec 2003 from Google searching.
I want to ask about (1) how to write for the "Check an Error" and (2) Am I on right track?, before completed the Sunday and Holiday code.
I want to add the weekend date with condition and have a Holiday table.
I came up this code with modified this
http://www.codeproject.com/Articles/...-Holidays-Week and Working With Business Dates (Business Holidays/Weekends, Etc) By glitch177k, 9 Dec 2003 from Google searching.
Code:
'Get the Business and weekend date, base on the date and duration.. passed 'Funtion dim sDate as d = {4/5/13} dim vDuration as n = 6 Dim iday as c dim iDaysToAdd as n dim idate as d valldate ="" dim vSatDate as d vListedDate ="" iDaystoAdd = vDuration idate = sDate Isholiday = .f. vAllowSun = .f. vAllowSat = .t. x = 1 for x = 1 to iDaysToAdd idate = (sDate-1)+x 'idate = (idate-1)+x 'ui_msg_box("count",str(x)+" Date "+idate ) If dow(idate)=7 .or. dow(idate)=1 .or. Isholiday =.t. then select case dow(idate) = 1 'Sunday msgbox("sunday","what to do ?") If vAllowSun = .t. then 'add date else 'donot add on the list and add 1 day for looping idate = idate '(sDate-1)+x-1 iDaysToAdd = iDaysToAdd +1 end if case dow(idate) = 7 'Saturday msgbox("Saturday","how ?") If vAllowSat = .t. then 'add date ui_msg_box("test Current date ",idate) vSatdate = idate vListedDate = vListedDate+cdate(vSatdate)+" "+cdow(iDate)+crlf() else 'donot add on the list and add 1 day for looping idate = idate iDaysToAdd = iDaysToAdd +1 end if case else If isHoliday = .t. then msgbox("Holiday ") end if end select else msgbox("week day",cdow(idate)) vListedDate = vListedDate+cdate(iDate)+" "+cdow(iDate)+crlf() 'iDaysToAdd = iDaysToAdd - 1 [COLOR="#FF0000"][B]'It reduced the looping value before next. I got wrong date on test result[/B][/COLOR] end if next x 'How to check the error 'Reduce the number of loop iDaysToAdd = iDaysToAdd - 1 If iDaysToAdd>0 then msgbox("more date",str(iDaysToAdd)) 'Still remained 6 end if ui_msg_box("test all date ",vListeddate)