extracting week number and year from date

Julia_P

New Member
Joined
Feb 18, 2016
Messages
7
Hi all,

I need help with extracting the week number and year from a certain date in excel and I don't get the correct information when a week contains different years. I am using this formula:

=CONCATENATE(YEAR(A2)," ",TEXT(WEEKNUM(A2,21),"00"))

and I get these results:
12/31/2015: 2015 53


1/1/2016: 2016 53

The result for 1/1/2016 should be 2015 53 as week 1 2016 starts on 1/4/2016 as per the European system.

Can somebody help me how to get the correct result?

Thanks!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Julia_P

New Member
Joined
Feb 18, 2016
Messages
7
Now I get for 1/1/2016: 2016 1. Firstly, in the European system, the first week of the year needs to include at least 4 days of January, which means that 1/1/2016 should be considered in the last week of 2015 and not in the first week of 2016. Secondly, I need the week to have two digits (so 01 instead of 1)
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,203
Now I get for 1/1/2016: 2016 1. Firstly, in the European system, the first week of the year needs to include at least 4 days of January, which means that 1/1/2016 should be considered in the last week of 2015 and not in the first week of 2016. Secondly, I need the week to have two digits (so 01 instead of 1)

If you are on Excel 2013 or beyond...

=YEAR(A2)&" "&TEXT(ISOWEEKNUM(A2),"00")
 

Julia_P

New Member
Joined
Feb 18, 2016
Messages
7

ADVERTISEMENT

It still results year 2016:
12/31/2015 2015 53
1/1/2016 2016 53

These two days are in the same week and I need it to show the same year and week number, respectively 2015 53
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,203
It still results year 2016:
12/31/2015 2015 53
1/1/2016 2016 53

These two days are in the same week and I need it to show the same year and week number, respectively 2015 53

Here is a tweak:

=YEAR(A2)-(ISOWEEKNUM(A2)<>WEEKNUM(A2,2))&" "&TEXT(ISOWEEKNUM(A2),"00")

Hope it survives further scrutiny...
 

Julia_P

New Member
Joined
Feb 18, 2016
Messages
7

ADVERTISEMENT

It fixes the week 53 2015 but what should be week 1 2016 results in 2015 01:

1/3/2016 2015 53
1/4/2016 2015 01
 

Watch MrExcel Video

Forum statistics

Threads
1,130,448
Messages
5,642,218
Members
417,262
Latest member
andrewd1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top