I think I got it. Had to extract year, month and date separately. Then get the current date. Use If statement to check if current month is greater than birth month, if so set birthdate to next year, else set it to this year.

// Get Date of Birth Entry
var dOb = @DOB;
// Extract Birth Month
var birthMonth = dOb.getMonth();
// Extract Birth Date
var birthDate = dOb.getDate();
// Extract Birth Year
var birthYear = dOb.getFullYear();
// Get Today's Date
var today = new Date();
// Get Today's Month
var curMonth = today.getMonth();
// Get Today's Year
var curYear = today.getFullYear();
// Get This Year's Birthday
var curYearBirthday = new Date(curYear, birthMonth, birthDate);
// Get Next Year's Birthday
var nextYearBirthday = new Date(curYear +1, birthMonth, birthDate);
// If the current month is bigger than than the birth month set this date to the birthday of next year
if (curMonth > birthMonth)
nextYearBirthday;
// Else, set the birthday to this year's birthday
else
curYearBirthday

Hi Nathan,

sorry to disappoint you: But var today = new Date(); doesn't work. You'll  get the date of the day you save the template (or a new item) - next year you'll have the same 2018 date.

Rainer

var date = @Geboortedatum

diffYears = moment().diff(moment(date),'years');

diffYears += 1;
}

@Felix
That doesn't work. See my comment above. In the calculation you need a variable which changes every day.

Oh wow, thank you!

Hi guys,

Has anyone managed to get a birthday field to work with a calculation?