setYear

Modified on Tue, 22 Aug 2023

Description

Use this function to set the year to the given date. You can specify the desired year using the "year" parameter. The function will return the resulting date with the specified year.

Syntax

setYear(date, year)

Returns

Return ValueDescription
DateReturn the resulting date.

Sample

ExampleResultDescription
setYear(2023-4-10, 2024)2024-04-10Set the year to 2024.

To view all the Date functions, click here.

See Also