简体   繁体   中英

Excel - How to convert the combination of year, week number and day of week to calendar day?

Have >80000 records of the type:

Year Week Weekday
1971 40 1
1998 25 7
2020 34 3

In Excel, I want to convert the data (year: 1971-2020, week: 24-44, weekday: 1-7) to the calendar day (1-365; total number of days per year varying from year to year). Any suggestions? I find related posts, but none that solves my problem.

Leaving aside the regional specifics of what constitutes week 1 in a year where January 1 is not on the same day as the perceived start of the week, you can arrive at a running day number for each date by multiplying the week by 7 and adding the day.

= (Week * 7 ) + Weekday

Apply your regional settings of a Monday vs Sunday week start by adding or subtracting one day.

You can then even come up with a date using that number.

=date(Year,1, (Week * 7 ) + Weekday)

This will use the first day of January as the first week, though. If that doesn't suit, you'll need to adjust by working out what week 1 means in any one year.

Edit:

Here is a table with your sample data:

在此处输入图像描述

The formula for year day is

=[@Week]*7 

The formula for adjust year start is

=WEEKDAY(DATE([@Year],1,1))

The formula for the final date is

=DATE([@Year],1,[@[year day]])-[@[adjust year start]]

You can see that year 2020, week 53, day 5 is shown as 1st January 2021, so that matches up. You can move the adjust year start calculation into the year day column, of course.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM