In mySql how can I calculate the months and years from a ‘given date’ till now. That ‘given date’ will be selected from a table. Or is this something I’ll have to use php to do?
So the sql will be select min(datecol) from table where userid = 12;
I came across this here select DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), '2009-12-26')), '%c months and %Y years'); but this gives 1 months and 0003 years
Three years is ok, but 1 month is wrong. It should be 36+ months in this case.
To find month
or this
refer the
Mevin Babulink to find year