3 Replies Latest reply on May 2, 2015 6:11 AM by philmodjunk

    Help with getting date range

    danlee

      Title

      Help with getting date range

      Post

      I have a field, MPQuota, with calculation:

      Let ([
      SummaryYrMo = Year(Date_Meal Plan) & Right ("0"&Month (Date_Meal Plan); 2);
      Today= GetAsDate (Get(CurrentHostTimeStamp));
      TodayYrMo = Year (Today) & Right ("0" & Month (Today); 2)];

      Case (TodayYrMo = SummaryYrMo; 1; 0)
      )

      This gives me a "1" if the date for field Date_Meal Plan is in the current month.  How do I change that to get the same thing for dates a month prior, 2 months prior, 3 months prior, etc.  I will create separate fields for those calculations.

      Thank you

        • 1. Re: Help with getting date range
          philmodjunk

          Let ([
                  ThetMonth = Date ( Month ( Date_Meal Plan ) ; 1 ; year ( Date_Meal Plan )  ;
                  Today = Get ( CurrentDate ) ;
                   LastMonth = Date ( Month ( Today ) -1 ; 1 ; Year ( Today ) )
                  ];

                  Lastmonth = ThatMonth
                 ) // Let

          Note that the Boolean expression: LastMonth = ThatMonth returns the number 1 if True and 0 if False so there's no need for the Case function.

          • 2. Re: Help with getting date range
            danlee

            I put that into calculation field and get, "There are too many parameters in this function."

            • 3. Re: Help with getting date range
              philmodjunk

              Which means that there is an extra or missing parenthesis in what I posted.

              Let ([
                      ThetMonth = Date ( Month ( Date_Meal Plan ) ; 1 ; year ( Date_Meal Plan ) ) ;
                      Today = Get ( CurrentDate ) ;
                       LastMonth = Date ( Month ( Today ) -1 ; 1 ; Year ( Today ) )
                      ];

                      Lastmonth = ThatMonth
                     ) // Let