Community
Participate
Working Groups
Build Identifier: 3.7.0.v20110603-BDF9E7AGTzuHfngz-8A08WvWDv8v It would be great to have a built in Javascript function which converts dates to an age. Reproducible: Always
I used the following snippet to convert the birthday from format dd.mm.YY to an age function getAge(birthday) { if(birthday==null) return tmpYear = birthday.substr(6,2) if(tmpYear>11) year = "19"+tmpYear else year = "20"+tmpYear month = birthday.substr(3,2) day = birthday.substr(0,2) today = BirtDateTime.today() fixedBirthday = year + "-" + month + "-" + day age = BirtDateTime.diffYear(fixedBirthday, today) if(BirtDateTime.month(today)<month) age = age - 1 else if (BirtDateTime.month(today)==month) { if(BirtDateTime.day(today)<day) age = age - 1 } return age } I'm sure, this can be done better - but some sort of function would be great to have in core birt