isSameWeek

Modified on Tue, 22 Aug 2023

Description

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

Syntax

isSameWeek(dateLeft, dateRight, options)

Returns

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

Sample

ExampleResultDescription
isSameWeek(2023-08-14, 2023-08-20)trueBoth dates, August 14th, 2023, and August 20th, 2023, fall within the same week, month (August), and year (2023), so the function returns true.
isSameWeek(2023-08-14, 2023-09-21)falseThe two dates fall in different weeks (second and fourth weeks of their respective months), so they are not in the same week, month, and year, and the function returns false.

To view all the Date functions, click here.

See Also