isSameYear

Modified on Tue, 22 Aug 2023

Description

Use this function to check if two given dates fall within the same year. It returns true if the two dates are in the same year, and false otherwise.

Syntax

isSameYear(dateLeft, dateRight)

Returns

Return ValueDescription
True/FalseReturns true if the two dates are in the same year, otherwise false.

Sample

ExampleResultDescription
isSameYear(2023-08-14, 2023-12-25)trueBoth dates, August 14th, 2023, and December 25th, 2023, fall within the same year (2023), so the function returns true.
isSameYear(2023-08-14, 2024-09-21)falseThe two dates are in different years (2023 and 2024), so they are not in the same year, and the function returns false.

To view all the Date functions, click here.

See Also