Access 2010 calculating the number of workdays -


i new access 2010 , need number of days in workweek excluding holidays twist. have been able use standard vb code workdays appears on internet , works great simple monday – friday or monday - saturday calculation. question is, how can or possible manipulate code calculate number of days if friday, saturday , sunday count 1 day?

example: calculate number of days tuesday 11/25/14 today.

  1. -today's date = monday, december 01, 2014;
    -monday, december 01, 2014 = 0;
    -sunday, november 30, 2014 = 3;
    -saturday, november 29, 2014 = 3;
    -friday, november 28, 2014 = 3;
    -thursday, november 27, 2014(holiday) = 2;
    -wednesday, november 26, 2014 = 2;
    -tuesday, november 25, 2014 = 1

so in example above, number of days 3.

if need account statutory holidays you'll need use kind of table. purely algorithmic approaches problem difficult manage , prone failure, because

  1. holidays fall on fixed date may observed on other date. example, if christmas falls on saturday employees may day off on friday.
  2. some holiday dates difficult calculate. in particular, good friday defined (here in canada, @ least) "the friday before first sunday after first full moon following spring equinox".

in simplest form, [datestable] this:

thedate     dayoff  comment          ----------  ------  ---------------- 2014-11-21  false                    2014-11-22  true    saturday         2014-11-23  true    sunday           2014-11-24  false                    2014-11-25  false                    2014-11-26  false                    2014-11-27  true    thanksgiving day 2014-11-28  false                    2014-11-29  true    saturday         2014-11-30  true    sunday           2014-12-01  false                    2014-12-02  false                    

counting number of work days between 2014-11-25 , 2014-11-30 (inclusive) be

select count(*) workdays  datestable  thedate between #2014-11-25# , #2014-11-30#     , dayoff=false; 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -