not calculate weekends

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

    #1

    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
    • 482

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

    Comment

    • abidoss
      Senior Member
      • Mar 2023
      • 252

      #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
      • 252

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

      Comment

      • yuri
        EspoCRM product developer
        • Mar 2014
        • 9617

        #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.

        Comment

        • abidoss
          Senior Member
          • Mar 2023
          • 252

          #6
          Can you give me a correct formula?

          Comment

          • yuri
            EspoCRM product developer
            • Mar 2014
            • 9617

            #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).

            Comment

            • abidoss
              Senior Member
              • Mar 2023
              • 252

              #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
              • 252

              #9

              Comment

              • rabii
                Active Community Member
                • Jun 2016
                • 1369

                #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
                EspoCRM & Web Dev

                🔗 See what I’ve built for EspoCRM

                Comment

                • abidoss
                  Senior Member
                  • Mar 2023
                  • 252

                  #11
                  Thanks

                  Comment

                  Working...