| Title: | JAVA | 
| Moderator: | KOALA::CIOT | 
| Created: | Mon Nov 13 1995 | 
| Last Modified: | Wed Jun 04 1997 | 
| Last Successful Update: | Fri Jun 06 1997 | 
| Number of topics: | 236 | 
| Total number of notes: | 1251 | 
Hi,
I had a problem calculating the exact age in Javascript.
Given a date : how to calculate the exact age? What i did
is to convert both now:Date and birthday:Date to seconds then 
extract them. the problem now is no "mod" function to extract the
exact nomber of years, months ...etc. Did i miss some functions or
methods?
Thanks for any hint.
P.S. Calculating field by field is not really helping such as :
     Nodays = now.getDay() - birthday.getDay();
Hussein SALEM
| T.R | Title | User | Personal Name | Date | Lines | 
|---|---|---|---|---|---|
| 207.1 | Subtract the years, compare the days | WIBBIN::NOYCE | Pulling weeds, pickin' stones | Mon Feb 17 1997 16:26 | 17 | 
| Here's how I do it in DCL:
$ y = f$cvtime(p1,,"year")
$ t = f$cvtime("",,"year")
$ a = f$integer(t)-f$integer(y)
$ if f$extract(5,99,f$cvtime("")) .lts. f$extract(5,99,f$cvtime(p1)) -
  then a = a-1
$ write sys$output a
Example:
$ @age 15-jul-1954
42
$ @age 15-jul-54
-58		(oops!)
 | |||||
| 207.2 | CECAMO::SALEM_H | Tue Feb 18 1997 04:53 | 6 | ||
| Thanks for your reply .. i can do it in other languages like C/C++ even Java but i miss some functions in Javascript and that was my question. Thanks any way. Hussein SALEM | |||||
| 207.3 | CECAMO::SALEM_H | Tue Feb 18 1997 06:35 | 5 | ||
| I found it, it is Math.round(); Thanks for all/ Hussein | |||||