not calculate weekends

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abidoss
    Senior Member
    • Mar 2023
    • 230

    not calculate weekends

    Hello

    How to add to this code of did not calculate weekends

    ic = datetime\diff(datetime\now(), availability, 'days')

  • Kharg
    Senior Member
    • Jun 2021
    • 410

    #2
    I think that you could use the working time calendar for this. Take a look:

    Comment

    • abidoss
      Senior Member
      • Mar 2023
      • 230

      #3
      It does not work

      Comment


      • yuri
        yuri commented
        Editing a comment
        What does not work. Why we need to guess.
    • abidoss
      Senior Member
      • Mar 2023
      • 230

      #4
      The settings are good, but it calculates the days week-end

      Comment

      • yuri
        Member
        • Mar 2014
        • 8453

        #5
        Your formula from the first post it not supposed to take into account working calendar. You need to use other functions from the article.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • abidoss
          Senior Member
          • Mar 2023
          • 230

          #6
          Can you give me a correct formula?

          Comment

          • yuri
            Member
            • Mar 2014
            • 8453

            #7
            Code:
            $numberOfDays = availability; // this just for readability
            
            ic = ext\workingTime\addWorkingDays(datetime\now(), $numberOfDays);
            Note that the working time calendar should be applied to the system (Administration > Settings > Working Time Calendar).
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • abidoss
              Senior Member
              • Mar 2023
              • 230

              #8
              $numberOfDays not recognized in entity formula

              Comment


              • rabii
                rabii commented
                Editing a comment
                what do you mean ? $numberOfdays is just a variable that holds the value of your field. make sure that you have the correct field name.

              • abidoss
                abidoss commented
                Editing a comment
                ic = datetime\diff(datetime\now(), disponibilit,'days') it works but it calculates over 7 days

                $numberOfDays = disponibilit ; // ceci juste pour la lisibilité
                ic = ext\workingTime\addWorkingDays(datetime\now(), $numberOfDays); it doesn't work it no longer calculates
            • abidoss
              Senior Member
              • Mar 2023
              • 230

              #9

              Comment

              • rabii
                Active Community Member
                • Jun 2016
                • 1250

                #10
                Just remove the line //this is for readibility
                try this instead
                Code:
                $numberOfDays = disponibilit;
                ic = ext\workingTime\addWorkingDays(datetime\now(), $numberOfDays);
                as yuri mentioned (Note that the working time calendar should be applied to the system (Administration > Settings > Working Time Calendar).)​
                Rabii
                Web Dev

                Comment

                • abidoss
                  Senior Member
                  • Mar 2023
                  • 230

                  #11
                  Thanks

                  Comment

                  Working...