Sign in to Community
Sign in to view all badges
I can't get my code to work, I've read over most of the other posts regarding Adding days to a date, and I'm can't figure out why my code isn't working.
Date1 field is a Date/Time field: I want the user to select a date
Date2 field is a field that I would like a new date (Date1 + 21 days) to automatically populate.
Here is my code, it is set to run when the user exits Date1.
var Date1 = Date2Num ($, "yyyy-mm-dd")
Date2 = Num2Date (Date1 + 21, "yyyy-mm-dd")
The result is y-m-d in the Date2 field. I have tried making Date2 a text field, numeric field, and another Date/Time field, the result is always the same.
I just sent it back. I was having some issues getting it to work according to the docs and how I recommended. Here is the code I used to get it to work properly. I used the ISO and manipulated the date from there.
var dateNumber = IsoDate2Num($)
topmostSubform.Page1.GerminatorDate.rawValue = Num2Date(dateNumber + 21)
Email is coming your way
Could you send me the form with a description of what you are looking for it to do?
ndjustin20 at hotmail dot com
Both fields are FormCalc...though there is no formula in the Date2 field.
I used your formual and the result is still the same, only now the result is m/d/y.
Make sure you are using FormCalc as both Date2Num and Num2Date are FormCalc functions and NOT js functions.
newDateField = Num2Date(Date2Num(dateFieldWithDateNeedingToChange, "MM/DD/YYYY") + 21, "MM/DD/YYYY")