yyyyww formula

drom

Well-known Member
Joined
Mar 20, 2005
Messages
528
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Hi and Thanks in advance

I have a Column with DATES

I need a colum with YYYY-WW, check Column Expected

To get the correct WeekNumber we have to use =WEEKNUM(DATE;21)

But accodng to this the Weeknumber the Year has to be modified manually (because I do not know how to do this by formula)

Have a look at this

The real Sheet is gonna have only 2 Columns DATE and Formula

DAYMONTHYEARDATEWeekNumber WEEKNUM(F14;$21)Expected (YYYY-WW)Formula??
01012019 2019-Jan-01 Tuesday012019-01
02012019 2019-Jan-02 Wednesday012019-01
03012019 2019-Jan-03 Thursday012019-01
04012019 2019-Jan-04 Friday012019-01
05012019 2019-Jan-05 Saturday012019-01
06012019 2019-Jan-06 Sunday012019-01
29122019 2019-Dec-29 Sunday522019-52
30122019 2019-Dec-30 Monday012020-01
31122019 2019-Dec-31 Tuesday012020-01
01012020 2020-Jan-01 Wednesday012020-01
02012020 2020-Jan-02 Thursday012020-01
29122020 2020-Dec-29 Tuesday532020-53
30122020 2020-Dec-30 Wednesday532020-53
31122020 2020-Dec-31 Thursday532020-53
01012021 2021-Jan-01 Friday532020-53
02012021 2021-Jan-02 Saturday532020-53
03012021 2021-Jan-03 Sunday532020-53
29122021 2021-Dec-29 Wednesday522021-52
30122021 2021-Dec-30 Thursday522021-52
31122021 2021-Dec-31 Friday522022-01
01012022 2022-Jan-01 Saturday522022-01
02012022 2022-Jan-02 Sunday522022-01
03012022 2022-Jan-03 Monday012022-01


Any help ?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I do not understand what the question is, or what you mean by this:
But accodng to this the Weeknumber the Year has to be modified manually (because I do not know how to do this by formula)
According to what?
Why does it need to be modified?
And how exactly does it need to be modified (what should it be showing that it is not)?
 
Upvote 0
I need a Formula to get Something similar to the Column F (Expected with the Formatting (yyyy-WW, yyyy= year with 4 number, ww, Week with 2 numbers formatting)
The Column F does no have a formula, but this is what I need
If the Date is in column D and the 1st of Janyuary 2021, WeekNumber is 53 (Using the Formula WeekNumber (2021-12-31,21))
I cant put in Column Formula the Following Formula:
=TEXT(YEAR(D2);"0000") & "-" & TEXT(WEEKNUM(D2;21);"00")
  • because I will get = 2021-53 ( year = 2021, WeekNumber = 53)
because this is Wrong
I need fo this date the answer = 2020-53

Column Expected is what I am trying to get
  • Where: in Column Formula
and The WeekNumber needs 21 as the second parameter, (return type)
 
Upvote 0
The weekNumber we use in our company can be obtained using
WeekNumber (2021-01-01, 21)
But when the First of january has 53 as the WeekNumber, this date belong to the prior year, So 2020-53
And if the 30th of December has as weeknumber 01 (eg: 30-12-2019) thw YYYY-WW I need a formula to get 2020-01
The The WeekNumber is easy, is DONE, but correct the year for those dates where the WeekNumber 01 has as month 12 or the the dates where the WeekNumer is 53 and the month 01 ??
 
Upvote 0
If I have understood correctly, it appears that your expected result column has three erroneous values near the bottom (12/31/2021 - 1/2/2022). If that is true, then this formula should work for dates beginning in D3.

Excel Formula:
=((MONTH(D3)=12)*(WEEKNUM(D3,21)=1))+((MONTH(D3)=1)*(WEEKNUM(D3,21)>=52)*-1)+YEAR(D3) & TEXT(WEEKNUM(D3,21),"-00")

Hope that helps.

Regards,
Ken
 
Upvote 0
Solution

Forum statistics

Threads
1,214,881
Messages
6,122,074
Members
449,064
Latest member
MattDRT

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
Back
Top