TEST!

To-do -

Logic -

  1. First, we parse the year such that it takes CURRENT year.
  2. Then we use parseDate to join the YYYY-MM-DD.
  3. Then we calculate the difference between PPD+1M and Today
  4. Same way we calculate difference between Next PPD+1M and Today
  5. To ensure neither of these values are negative, we take the max of these or 0.
  6. Then we take the minimum value of these 2 values - to see which is nearer to today and is not already gone past.
if(prop("Status") == "Active",
		lets(
			year,
			now().formatDate("YYYY"),
			premium,
			prop("PPD").formatDate("MM-DD"),
			nextpremium,
			prop("Next PPD").formatDate("MM-DD"),
			premiumdate,
			parseDate(join([year,premium],"-")),
			nextpremiumdate,
			parseDate(join([year,nextpremium],"-")),
			max(
				max(dateBetween(dateAdd(premiumdate,1,"months"),now(),"days"),0),
				max(dateBetween(dateAdd(nextpremiumdate,1,"months"),now(),"days"),0)
			)
		),
		"Matured"
	)

Sample database below -

Sample policies

Published by @Mayank Agarwal | Mail me here