How to get field to advance to the 1st of the next month

OlyChristine

20-03-2015

I am trying to figure out how to get a date field (effDate1) to advance to the first of the next month from the previous date field (retireDate1). For example, if I enter 03/20/2015 in the field titled retireDate1 - the next date field, titled effDate1, needs to be the 1st of the following month - 04/01/2015. Any help is greatly appreciated!!

FormCalc

Date Pattern: MM/DD/YYYY

Accepted Solutions (0)

Answers (3)

Answers (3)

jasotastic81

20-03-2015


if (HasValue(retireDate1)) then


  var retireDate1_ = Date2Num(retireDate1.formattedValue, "MM/DD/YYYY")


  retireDate1_ = retireDate1_ + 1


  while (Substr(Num2Date(retireDate1_,"MM/DD/YYYY"),4,2 ne "01") do


    retireDate1_ = retireDate1_ + 1


  endwhile


  $ = Num2Date(retireDate1_, "MM/DD/YYYY")


endif


See if that works for you.