Create new date from old date, keeping day and month entries from old date
Customer enters their date of birth (oDOB) in mm/dd/yy format in a text field named Date_of_Birth. I want to take this customer-entered oDOB and keep the mm/dd the same but bring the yy to the current year, creating new date named cDOB that consists of the original oDOB dd/mm values associated with the current year's yy value. This allows me to have a current date of birth (cDOB) from the customer's entered date of birth (oDOB). I then want to be able to use the current date of birth (cDOB) in date calculations to determine specific periods of time by adding or subtracting the current date of birth (cDOB) to/from a given date to get the number of days between these two dates. This last part I'm ok with- I have Tom's articles and looked at plenty of examples of date calculations, including try67's substring approach, but I just can't seem to get it- any help greatly appreciated- here's my latest edition of "lost count on how many times and ways tried" script- thanks in advance- kemper
if (dDOB === "") event.value = "";
else {
var TODAY = new Date ();
var currYR = TODAY.getFullYear();//gets current Year
var oDOB = this.getField("Date_of_Birth").valueAsString; //gets birthdate
var bd = new Date(oDOB);//creates birthdate
var bdmonth = bd.getMonth();//gets birthdate month
var bdday = bd.getDate();// gets birthdate day
var bdyear = currYR;// sets oDOB year to current year
var cDOB = new Date(bdmonth,bdday,bdyear);//creates current DOB
event.value = util.printd("mm/dd/yy",cDOB);
}