Collections:
PERIOD_DIFF() - Difference of Year-Month Periods
How to calculate the difference between two year-month periods using the PERIOD_DIFF() function?
✍: FYIcenter.com
PERIOD_DIFF(P1, P2) is a MySQL built-in function that
calculates the difference between two year-month periods.
For example:
SELECT PERIOD_DIFF(201802, 201703), PERIOD_DIFF(201703, 201802); -- +-----------------------------+-----------------------------+ -- | PERIOD_DIFF(201802, 201703) | PERIOD_DIFF(201703, 201802) | -- +-----------------------------+-----------------------------+ -- | 11 | -11 | -- +-----------------------------+-----------------------------+
Reference information of the PERIOD_DIFF() function:
PERIOD_DIFF(P1, P2): int Returns the number of months between periods P1 and P2. P1 and P2 should be in the format YYMM or YYYYMM. Arguments, return value and availability: P1: Required. The year-month period to be subtracted from. P2: Required. The year-month period to be subtracted. int: Return value. The difference in months. Available since MySQL 4.
Related MySQL functions:
⇐ PERIOD_ADD() - Adding Months to Period
2023-11-17, 1002🔥, 0💬
Popular Posts:
Where to find SQL Server database server tutorials? Here is a collection of tutorials, tips and FAQs...
How To Look at the Current SQL*Plus System Settings in Oracle? If you want to see the current values...
How to run Queries with SQL Server Management Studio Express in SQL Server? 1. Launch and connect SQ...
Where to find answers to frequently asked questions on PHP Connections and Query Execution for MySQL...
How to download and install Microsoft SQL Server Management Studio Express in SQL Server? Microsoft ...