4 Replies Latest reply on Nov 24, 2014 2:42 PM by Mike_Mitchell

    Workdays between dates including Saturday.

    tonymak

      Have found solutions to calcualte workdays (weekdays) between two given dates

      Example ( 10/1/2014 through 10/15/2014 )

       

      however the company i'm doing work for uses a 6 day workweek for sales, Mon through Saturday.

       

      so normally the above example would be 11 workdays without saturdays.

       

      any suggestions on how i can find the number of saturdays to add to the weekday calc would be great.

      ( 2 for the above example) making the 6 day week equal to 13 workdays starting 10/1/14 and completing 10/15/2014.)

       

       

      on the other side of that the factory works a 4 day week (Mon through Friday) so i also need to be able subtract fridays as well.

        • 1. Re: Workdays between dates including Saturday.
          Mike_Mitchell

          Here's a CF that includes an option for Saturdays. You should be able to adapt it for Fridays as well.

           

          ------------------------------------------------------------------------------------------------------------------------------------------------------

           

           

          /*

          cfWorkingDays adapted from Barbecue, Le Kastelo de Barbakoa

           

          cfWorkingDaysBetweenDates ( start ; end ; saturday )

           

          Returns the number of working days between the start and end dates

          Returns a negative number if start is earlier than end

          Passing a "y" in saturday indicates that saturday is a working day

           

          */

           

          Let ( [

           

          startdate = If ( start ≤ end ; start ; end ) ;

          enddate = If ( start ≤ end ; end ; start ) ;

          weekEnd = If ( saturday = "y" ; 8 ; 7 ) ;

          startDay = DayOfWeek ( startdate ) ;

           

          days = Case (

            startdate < enddate ;

            ( startDay > 1 and startDay < weekEnd ) + cfWorkingDaysBetweenDates ( startdate + 1 ; enddate ;  saturday ) ;

            0

          )

           

          ] ;

           

          If ( start ≤ end ; days ; 0 - days )

           

          )

          • 2. Re: Workdays between dates including Saturday.
            tonymak

            Thank you VERY much, works really great.

            • 3. Re: Workdays between dates including Saturday.
              lrawlins

              Hi,

               

              I have stumbeled on to your post about CF for workdays.

               

              While I have been using FileMaker for decades I am not at all familiar with Custom Functions.

               

              I am using FMP Advanced 13.04

               

              I go to Manage > Custom Functions and select new function then past this solution. The only thing I get is an error message that parameters can not be found.

               

              What am I overlooking?

               

              Thanks

              • 4. Re: Workdays between dates including Saturday.
                Mike_Mitchell

                In the upper left-hand corner of the Custom Function dialog, there's a section for parameters:

                 

                Screen Shot 2014-11-24 at 5.40.48 PM.png

                 

                You'll need to insert the name of each parameter and click the green "+" icon (or just press "Return") in order to create them.