Loading lesson path
Concept visual
Start at both ends
Return the difference between two periods:
SELECT PERIOD_DIFF(201710, 201703);The PERIOD_DIFF() function returns the difference between two periods. The result will be in months.
period1 and period2 should be in the same format.
PERIOD_DIFF( period1, period2 )
Required. A period. Format: YYMM or YYYYMM period2 Required. Another period. Format: YYMM or YYYYMM
From MySQL 4.0
Return the difference between two periods:
SELECT PERIOD_DIFF(201703, 201803);Return the difference between two periods:
SELECT PERIOD_DIFF(1703, 1612);❮ MySQL Functions