Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
duration.m onths remains 0
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-10-2012 07:33 AM
I am trying to calculate a person's age in years.
Duration has no years, only months but that stays 0?!?
See following code:
bd is a date;
age is a duration;
bd = '10-June-2012';
age = calendar().currentDate().subtractInDays(bd);
print("d: " age);
print("age in days: " age.days);
print("age in months: " age.months);
What am I doing wrong?
Solved! Go to Solution.
Re: duration.m onths remains 0
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Not the Solution
- Email to a Friend
- Report Inappropriate Content
07-11-2012 09:09 AM
found it, am now using substractInMonths
and taking floor(age.months / 12)

