Re: getting age with month

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In message <eeadcf600706090718j61c913f4qeec40af7f4e0c4f3@xxxxxxxxxxxxxx>
, Farhan khalid <farhan2kf@xxxxxxxxx> writes
>Hi,
>
>I need to get accurate age of user with month from date of birth stored in
>mysql
>
>date is stored in mysql like this 1983-05-05 and i need to show age like
>this 23 year 11 month
>
>I have calculated years but months are not calculating correctly

In the PHP manual, there is an example, which, translated into your
requirements, would be 
SELECT MOD( PERIOD_DIFF( DATE_FORMAT( NOW(),'%Y%m'), DATE_FORMAT(birthda
te,'%Y%m')),12) FROM people;

which gives the months. 

So using whatever you have for your code, and the above, you can return
two columns, one with year, and one with months. 

You could return it in one column, using different SELECTs if you wanted
to.
-- 
Pete Clark

Sunny Andalucia
http://www.hotcosta.com/comm_1.htm

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux