Change Date to show Year & Week of the Year

bobgrand

Board Regular
Joined
Apr 14, 2008
Messages
220
Hello all, I hope we are all being safe these days.

I am trying to create a formula to change the date 2/14/2020 to be a Year & Week of the year format.

Examples
DATE ------- Converted to YYWK
2/14/2020 = 2007
2/21/2020 = 2008
2/28/2020 = 2009
3/6/2020 = 2010
3/13/2020 = 2011

Any help would be greatly appreciated.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,301
Office Version
  1. 365
Platform
  1. Windows
If you don't have the ISOWEEKNUMBER function, then you can use
=WEEKNUM(A2,21)
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,858
Office Version
  1. 2010
Platform
  1. Windows
I had a misplaced opening parentheses... I think this should work correctly. If you test it, you might want to do so over a 10 year period so that a couple of Leap Years are spanned. Obviously, you will use a formula to mark any differences rather than trying to "eye it".

=INT(MOD(MOD(28*MOD(INT((A1+692501)/7),20871)+4383,146096),1461)/28)+1
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,858
Office Version
  1. 2010
Platform
  1. Windows
@gaz_chops... Thanks! Supposedly, the code I transcribed it from says it is good up to and including the year 9999. With that said, Fluff's WEEKNUM suggestion in Message #11 seems just a wee bit simpler to use.:ROFLMAO: Just for context, the VBA code that I used to construct my formula was created because in VBA, the DatePart function has a bug in it for week numbers... the VBA code I translated does not.

@Fluff... I was not aware of the 21 argument for WEEKNUM. What I am now trying to figure out is why are there two codes for "System 1" Mondays (2 and 11)?
 

gaz_chops

Well-known Member
Joined
Apr 29, 2003
Messages
6,468
Platform
  1. MacOS

ADVERTISEMENT

Seems Excel fails with dates beyond 9999, but your formula appears to keep working, can't check the accuracy as nothing else works!!

1594929175249.png
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,301
Office Version
  1. 365
Platform
  1. Windows
No idea, what the difference is between 2 & 11 (or 1 & 17)
But originally only 1 & 2 were available, the rest arrived with 2010
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,858
Office Version
  1. 2010
Platform
  1. Windows
@gaz_chops... Okay, let's say it is correct then. I mean, there will probably be a mad rush to use it for dates after the year 9999 now.:giggle:

@Fluff... I have XL2010 and never noticed they expanded the argument list.:(
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,301
Office Version
  1. 365
Platform
  1. Windows
I've very rarely ever used the weekday function & when I did that was on Excel 2003.
I only discovered the 21 argument because of this thread & in the process the fact that they added the extra options in 2010.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,098
Messages
5,622,678
Members
415,921
Latest member
ExcelNoob28

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