MySQL Forums
Forum List  »  Newbie

Re: SELECT DATEDIFF Help
Posted by: danish hafeez
Date: February 27, 2024 11:40PM

To calculate the difference between two dates in years, you can use the DATEDIFF function to get the difference in days and then divide that by 365.25 (to account for leap years) to get the approximate difference in years. Here's how you can do it:

sql
Copy code
SELECT DATEDIFF("2010-05-07", "2004-04-20") / 365.25 AS difference_in_years;
This will give you the approximate difference in years between the two dates. Keep in mind that this approach considers a year to be 365.25 days to account for leap years.

Best Regard
Danish Hafeez | QA Assistant
https://www.ictinnovations.com

Options: ReplyQuote


Subject
Written By
Posted
February 27, 2024 10:00PM
February 27, 2024 10:03PM
Re: SELECT DATEDIFF Help
February 27, 2024 11:40PM
February 27, 2024 11:51PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.