Hi. I want to get the difference between two dates in years. I have this: SELECT DATEDIFF("2004-04-20","2010-05-7") Code (SQL): The result is shown in days. I need show this in years. Exist another way? Can some one help me? Thanks.
Then just format it? Should be possible to just do: $diff = $datetime1->diff($datetime2)->format('Y'); Code (markup):
With the DATEDIFF function, you are able to select what format you want to result returned in. For example: DATEDIFF( datepart, start_date, end_date). You can replace the datepart variable with something like hour, day, week, year.