Adding ‘Week of Year’ Formula in Saved Search

When the function Week of Year is added to a saved search, it shows the year and week number based on the first day of the year as the start of the week regardless of the day. 

The Week of Year function shows the week number based on the first day of the year. 

Date: 01/21/2019 
First Day of Week: Sunday 
First Day of the Year: 01/01/2019 | Tuesday 
Week 1: 01/01/2019 – 01/07/2019 
Week 2: 01/08/2019 – 01/14/2019 
Week 3: 01/15/2019 – 01/21/2019 
Week of Year: 2019-03 

The Week of Year function does not respect the First Day of Week general preference and uses the first day of the year as the basis for the start of the week. 

Having the Week of Year function to consider what is selected under Setup > Company > General Preferences > First Day of Week is currently under Enhancement # 171746

Calendar Week function 

This function shows the date that falls as the first day of the week depending on what is selected under Setup > Company > General Preferences > First Day of Week

For example: 

Date : 01/21/2019 

First Day of Week: Sunday 

Calendar Week: 01/20/2019 

To add this to the Saved search formula, Select Formula (Text) 

TO_CHAR({trandate}, 'YYYY') || ' ' || '-' || ' ' || TO_CHAR({trandate}, 'IW') 

NoteYou may change the {trandate} depending on the field you want to use as a basis as there are 3 to_char format models to get the week number: 

W    – week number in a month 
WW – week number in a year, week 1 starts on 1st of Jan 
IW   – week number in a year, according to ISO standard  

Notes:  
In the ISO standard ( ‘IW’ ), the week number can be different from the week number of the calendar year. For example, 1st Jan 1988 is in ISO week number 53 of 1987. An ISO week always starts on a Monday and ends on a Sunday. 
 
If January 1 falls on a Friday, Saturday, or Sunday, then the ISO week that includes January 1 is the last week of the previous year, because most of the days in the week belong to the previous year. 
 
If January 1 falls on a Monday, Tuesday, Wednesday, or Thursday, then the ISO week is the first week of the new year, because most of the days in the week belong to the new year. 

Leave a comment

Your email address will not be published. Required fields are marked *