I’ve been trying to calculate the date of birth from Google Apps Script with a Google Sheets database for a few days. The idea was the following:
-
The users respond to a form
-
My script collects their answers and generates an individual document for each one (based on a template) with their data
var date= new Date(); var month= date.getMonth() + 1; var day= date.getDate(); var year = date.getFullYear(); var today= day + "/" + month+ "/" + year const searchTextE = "<<age>>"; const replaceTextE = Math.round((parseInt(today) - parseInt(hojaActual.getRange("with it's located the birth date").getValue()))/365.3);
I also tried entering the date in date format (the option that the form itself gives you), but it came out with Central European time, and I only wanted it to tell me the date in this format dd/mm/yyyy, wich with the text format has been possible.
So, once the date of birth was entered (in text format) my idea was that the age could be calculated automatically (without having to ask the users) with my code, but when I look at the cell in the individual document I only see a 0.