| Summary: | Javascript function to convert birthday to age | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Sascha Vogt <sascha> |
| Component: | BIRT | Assignee: | Birt-Data-inbox <Birt-Data-inbox> |
| Status: | NEW --- | QA Contact: | Xiaoying Gu <bluesoldier> |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | bluesoldier |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Sascha Vogt
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
|