The getWeekOfYear() function takes a dateTimeValue as an argument, and returns a number representing the week of the year in which the specified dateTimeValue falls.

1 represents the first week, 2 represents the 2nd week, and so on, with 52 being the final number representing the last week of the year.

Note : A week starts from Sunday. Consequently, previous year's dates falling in the first week of the new year will return 1.

Return Type

  • Number


<variable> = <dateTimeValue>.getWeekOfYear([start_day]);


<variable> = getWeekOfYear( <dateTimeValue>, [start_day]);
ParameterData typeDescription
<variable>NUMBERVariable which will contain the returned number.

The date-time value based on which a number will be returned.

The date-time value can be specified without a time value, in which case 00:00:00 will be taken as the default time value.

A runtime error will be encountered if:

  • the specified 2 digit date value exceeds the number of days in that month.
  • an incorrect month value is specified in 3 or more characters.

The function returns a null value if:

  • the month value is specified in less than 3 characters.
  • the hour value, or the minutes value, or the seconds value is specified in more than 2 digits.
  • the date value is specified in more than 2 digits.
  • the year value has more than 4 digits.

Refer this help document to learn about the supported date-time formats.


The day that will be considered as the first day of a week.

  • If this parameter is not specified "Sunday" will be considered as the first day of the week.


currentDate = '7-Feb-2021'; 
weekNumber = currentDate.getWeekOfYear(); // returns 7 considering "Sunday" as first day of a week 
// The following example is applicable only to services other than Zoho Creator 
currentDate = '7-Feb-2021'; 
weekNumber = currentDate.getWeekOfYear("Monday"); // returns 6 considering "Monday" as first day of a week

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: