Calculated field for Week Number not working for certain Sundays

Amy Stevens 20 Reputation points
2023-05-24T14:23:36.3666667+00:00

I'm using this formula in a Sharepoint calculated field to display week number in the format Year-Wk (e.g., 2023-05 for May).

=YEAR([Date of SEV Event]) & "-" & TEXT(IF(INT(([Date of SEV Event]-DATE(YEAR([Date of SEV Event]),1,1)+(TEXT(WEEKDAY(DATE(YEAR([Date of SEV Event]),1,1)-1),"DD")))/7)=0,52,INT(([Date of SEV Event]-DATE(YEAR([Date of SEV Event]),1,1)+(TEXT(WEEKDAY(DATE(YEAR([Date of SEV Event]),1,1)-1),"DD")))/7)),"00")

I've found at least 2 Sundays that show the previous week number - 2/26/23 and 1/1/23. Does anyone know how to fix that? I need this to work for dates starting in 2021 and going forward.

The Date of SEV Event column is Date only.

Thanks!

Amy

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

Accepted answer
  1. Xyza Xue_MSFT 30,176 Reputation points Microsoft External Staff
    2023-05-26T01:16:44.5433333+00:00

    Hi @Amy Stevens ,

    Use the following formula( it applies to every year):

    =YEAR([Date of SEV Event])&"-"&ROUNDUP((INT([Date of SEV Event])-DATE(YEAR([Date of SEV Event]),1,1)+1)/7,0)
    

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Xyza Xue_MSFT 30,176 Reputation points Microsoft External Staff
    2023-05-25T03:22:10.35+00:00

    Hi @Amy Stevens ,

    I improved your formula, please use the following formula:

    =YEAR([Date of SEV Event])&"-"&ROUNDUP((INT([Date of SEV Event])-44926)/7,0)
    

    Here are my test results:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.