MySQL PERIOD_DIFF() Function

MySQL | PERIOD_DIFF() Function: Learn about the PERIOD_DIFF() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 11, 2022

PERIOD_DIFF() Function

When you want to get the difference between two periods than in such case, we use this PERIOD_DIFF() function.

PERIOD_DIFF() Syntax

SELECT PERIOD_DIFF(period1, period2);

PERIOD_DIFF() Parameter(s)

This function takes two periods of dates which should have YYMM or YYYYMM as their format.

PERIOD_DIFF() Return Value

This function will return the number after taking out the difference between the two periods.

MySQL PERIOD_DIFF() Function Example 1

SELECT PERIOD_DIFF(202207,202204);
Example 1: MySQL PERIOD_DIFF() Function

In this example the YYYYMM format is used.

MySQL PERIOD_DIFF() Function Example 2

SELECT PERIOD_DIFF(0207,0102);
Example 2: MySQL PERIOD_DIFF() Function


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.