def getkids(objclass,EmpCode, healthFlag=False): kids = 0 query = Query() query.sql = "SELECT {Code},{BirthDate} FROM [Family] " query.sql += "WHERE?AND {EmpCode}=s|%s| " % EmpCode query.sql += "WHERE?AND {Relationship}=i|1|" # only kids below 18 if healthFlag: query.sql += " WHERE?AND {HealthFlag} = i|1| " if (query.open()): for kid in query: age = today() - kid.BirthDate if (age.days/365) < 18: kids += 1 return kids
function getKids(objclass, EmpCode, healthFlag=false) { kids = 0; query = Query(); query.sql = "SELECT {Code},{BirthDate} FROM [Family] "; query.sql += "WHERE?AND {EmpCode}=s|%s| " % EmpCode; query.sql += "WHERE?AND {Relationship}=i|1|"; // only kids below 18 if (healthFlag) { query.sql += " WHERE?AND {HealthFlag} = i|1| "; } if (query.open()) { for (kid in query) { age = today() - kid.BirthDate; if (age.days / 365) < 18 { kids += 1; } } } return kids; }