Categories | Question details Back To List | ||||||||
Best Way to Calculate Age - DHTMLXGRID I am using the DHTMLX GRID, and am importing a CSV that, among other things, contains birthdates. I would like to populate a column with their current age, based on the current date. I have tried mayn different things, but just can't figure out how to do this. Any help would be appreciated! Answer posted by Support on Oct 13, 2008 01:29 You can use code similar to next ( code suppouse that data stored in default mm/dd/yyyy format ) grid.attachEvent("onRowCreated",function(id){ var date = grid.cells(id,INDEX).getValue(); //get date var years = (new Date()).getYear()-(Date.parse(date)).getYear(); grid.cells(id,INDEX).setValue(years); //set years return true; }); INDEX - index of column in question Answer posted on Oct 14, 2008 20:29 I have tries this, and can't get it to work. I get Object does not exist errors. Answer posted by Support on Oct 15, 2008 01:49 Please check attached sample. Attachments (1)
Answer posted by Dennis Nederlof on Oct 16, 2008 00:24 Thanks! Now I see what I was doing wrong. I have to say... I am VERY IMPRESSED with the speed and quality of support! |