306 months = 25 years 6 months (...not 25.5 years)

306 months = 25 years 6 months (...not 25.5 years)

Post by Davi » Fri, 30 Jun 2006 08:25:57


I have a field that contains the number of months that a person has
lived. I can divide by 12 to get the number of years and the decimal
representation of the part of the year (if any) that remains (e.g., 306
months = 25.5 years).
-
What I want, though, is the number of years and the remainder displayed
as months (e.g., 427 months = 35 years, 7 months, etc..).
-
How would I do this? I've looked at various things, like MOD( ), but
I'm not getting it. I hope it is not too simple.
-
Thanks,
David
 
 
 

306 months = 25 years 6 months (...not 25.5 years)

Post by Imaginecor » Fri, 30 Jun 2006 08:43:12

Cant do it the way you want it, months have different number of total days,
can do this very easily by Dates but still involves writing code i.e. Born
on till today...
Mohammed

 
 
 

306 months = 25 years 6 months (...not 25.5 years)

Post by Gene Wirch » Fri, 30 Jun 2006 08:55:08


Sorry, but it is:<G>

monthslived=306
yearslived=int(monthslived/12)
partyearmonths=monthslived%12
? monthslived,yearslived,partyearmonths && 306 25 6

Sincerely,

Gene Wirchenko
 
 
 

306 months = 25 years 6 months (...not 25.5 years)

Post by Imaginecor » Fri, 30 Jun 2006 09:04:57

CHEERS... next round is on me

Totally missed the question, was thinking along From - To dates to convert
into years, months & days
Mohammed
 
 
 

306 months = 25 years 6 months (...not 25.5 years)

Post by Davi » Fri, 30 Jun 2006 10:25:03


Thanks very much! Oh, well. I'm glad I asked. Most likely I never
would have come up with a solution...
-
David
==============
 
 
 

306 months = 25 years 6 months (...not 25.5 years)

Post by AA » Fri, 30 Jun 2006 19:08:50

You can use date arithmetic:

dob=DATE(1964,5,7)
days=DATE()-M.dob
age=DATE(2000,1,)+M.days
? YEAR(M.age)-2000,MONTH(M.age),DAY(M.age)

-Anders

"David" < XXXX@XXXXX.COM > skrev i meddelandet
 
 
 

306 months = 25 years 6 months (...not 25.5 years)

Post by TWFya » Sat, 01 Jul 2006 00:55:02

Hi Anders,
Interesting approach, but you did not test it
Last row is
? YEAR(M.age)-2000, MONTH(M.age)-1, DAY(M.age)
hth
Mark
 
 
 

306 months = 25 years 6 months (...not 25.5 years)

Post by AA » Sat, 01 Jul 2006 19:06:55

Thanks for testing.
Another typo correction;
age = DATE(2000,1,1) + M.days

Should one count as 0 or 1 days old on the day one is born?
-Anders

"Mark" < XXXX@XXXXX.COM > skrev i meddelandet
 
 
 

306 months = 25 years 6 months (...not 25.5 years)

Post by Gene Wirch » Sun, 02 Jul 2006 02:07:02


0, since it is a measure of elapsed time.

[snipped previous]

Sincerely,

Gene Wirchenko