I hope this makes sense. I need:
1. User enters Start Date & Credits Earned
2. Associates Degree field would calculate Start Date + 1068 days (~35 months from the date entered)
3. If any credits have been earned to date, a variable (converting credits earned to a number of days, which I already have calculating correctly in a hidden field) would be subtracted
Start Date + 1068 days - Variable = Graduation Date
Any help would be appreciated.
Here's all you need, so far:
if (not $.isNull) then
var cPattern = "DD.MM.YYYY" ;How the entered date is formatted
var cStartDate = $.formattedValue ;The entered anf formatted date
var iStartDate = Date2Num(cStartDate, cPattern) ;The date converted into an integer
var iNumMonths = 35 ;Months to count
var iNumSubtractDays = 7 ;Value to be subtracted later.
var iNumCount = 0 ;Month counter
;A while loop that executed as long the desired number of months have been counted
while (iNumCount lt iNumMonths) do
;If current month is different to previous month …
if (Num2Date(iStartDate, "M") ne Num2Date(iStartDate - 1, "M")) then
;…add 1 month to the counter
iNumCount = Sum(iNumCount + 1)
;Add 1 day to the counter for the next iteration of the while loop
iStartDate = Sum(iStartDate, 1)
;Show result in textfield etc.
Textfield = Num2Date(Sum(iStartDate, -1, iNumSubtractDays), cPattern)
Add the script above into the exit event of you start date field and set the scripting language to FormCalc.