Datetime\add problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1606

    Datetime\add problem

    Hello,
    I want to calculate the end date after given start date by value of period.
    In other words: I have a start day and have to choose a period of 12, 24, 36 .... months (provided by enum field). In another field I want output of the end date by formula.

    My formula:

    Code:
    IfThen(
    period=12,
    endDate=(datetime\addYears(startDate, 1)
    );
    Then I apply that formula for each of the different periods, like period=24, period=36 etc. with year value accordingly increasing to 2,3, etc.
    The formula works, but it only uses the last period (60 months, 5 years, which is the last formula combination of five)). Whenever I choose another period, it jumps back to 60 months and applies 5 years.

    I don`t see the reason, is there something wrong with my formula?
  • yuri
    Member
    • Mar 2014
    • 8453

    #2
    You need to use == operator instead of =.


    period == 12
    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

    • shalmaxb
      Senior Member
      • Mar 2015
      • 1606

      #3
      yuri , thank you, I understand. But when I change to this operator, it does not calculate at all. Very strange.

      Comment

      • item
        Active Community Member
        • Mar 2017
        • 1476

        #4
        Hello,

        enumField ... try. =='12'
        or maybe another function.. but not time to test
        If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

        Comment

        • shalmaxb
          Senior Member
          • Mar 2015
          • 1606

          #5
          item, ok, that worked finally, well it has to be: period == '12'
          thankyou!

          Comment

          Working...