sure, Excel has a thing called NetWorkDays which does this for you, Access does not. so this is a solution that i've used to calculate business days.<br><b><br>If Weekday([yourfieldname]) + 2 = 1 Or Weekday([yourfieldname]) + 2 = 7 Then<br>'Weekday 1 is Sunday, Weekday 7 is Saturday<br> If Weekday([yourfieldname]) + 2 = 1 Then<br> BusDays = RecdDate + 3<br> End If<br> If Weekday([yourfieldname]) + 2 = 7 Then<br> BusDays = RecdDate + 4<br> End If<br>'adds 3 days if date+2 =Sunday, 4 days if date+2 =Saturday<br>Else<br> BusDays = yourfieldname + 2<br>End If<br>''''''''''''''''''''Brian C. Famous, 2000''''''''''''''''<br></b><br><br>put your date field in where it says "yourfieldname", and then have another field named [BusDays], or whatever you want to call it (but then you have to change BusDays in the code above too.<br><br>let me know if you have any questions. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
Brian solved the weekdays portion.<br><br>You may want to create a "Holidays" table and pre-fill it with your company holidays. Then you can check using...<br><br><FONT FACE=monospace><br>Dim HolidayCheck As Variant<br><br>HolidayCheck = 1<br><br>Do Until IsNull(HolidayCheck)<br><br> HolidayCheck = DLookup("dateHoliday","tblHolidays","dateHoliday = #" & dateToCheck & "#"<br><br> If IsNull(HolidayCheck) Then <br> ' Not a holiday<br> Else <br> dateToCheck = dateToCheck + 1<br> End If<br><br>Loop<br></font> <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
Thanks for the quick response.<br>Now how do I go about using this in an update query so that if it meets my criteria it updates another field to "Y"?<br><br>For instance<br>If [shipdate]=([promisedate]+2workdays) then<br>[twodayslate]="Y"<br><br>Once I get this to work then I will work on holidays
This will calculate promisedate+2 workdays in a query for you:<br><b><br>Workdays: IIf(weekday([promisedate])+2=1, [promisedate]+3, (IIf(weekday([promisedate]+2=7, [promisedate]+4, [promisedate]+2)<br></b><br><br>then in [twodayslate] put<br><b><br>IIf([shipdate]=[workdays],"Y"<br></b><br><br>you can make an update query out of that<br><br>this should work, but i didn't test it all. i've used the first part before, and i think this is what you mean. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.