简体   繁体   English

从周数和年份的excel日期

[英]excel date from week number and year

I have the following table in Excel that has year number and week number: 我在Excel中有下表,其中包含年号和周号:

Year               Week
-----             ------
2015               33
2014               41
2016               40

How can I get a 3rd column that has the date of the corresponding Friday for each row? 我如何获得第三列,每一行具有对应的星期五的日期? So, week 33 of 2015 should return: Friday, August 14, 2015. 因此,应该在2015年的第33周返回:2015年8月14日,星期五。

I have tried to use the date function, weeknum function, but cannot get any consistent results. 我尝试使用date函数,weeknum函数,但是无法获得任何一致的结果。

If you are using ISO week numbers then this formula will give the date you want 如果您使用的是ISO周数,则此公式将提供您想要的日期

=DATE(A2,1,B2*7+2)-WEEKDAY(DATE(A2,1,3))

where year is in A2 and week number in B2 年在A2中,星期数在B2中

Format in required date format 以要求的日期格式格式化

With ISO week numbers week 1 always starts on the first Monday on or after 29th December 使用ISO周编号,第1周始终在12月29日或之后的第一个星期一开始

Assuming the week starts on Sunday and non-ISO week-numbering, the date of the Sunday of Week#1 of any year is given by: 假设星期从星期日开始并且使用非ISO星期编号,则任何一年的第1周的星期日的日期由下式给出:

=CHOOSE(WEEKDAY(DATE(A2,1,1)),DATE(A2,1,1),DATE(A2,1,1)-1,DATE(A2,1,1)-2,DATE(A2,1,1)-3,DATE(A2,1,1)-4,DATE(A2,1,1)-5,DATE(A2,1,1)-6)

Then add 5 to move to Friday. 然后加5移至星期五。 Then add: 然后加:

(B2-1)*7

to advance to the proper week: 提前到适当的一周:

=CHOOSE(WEEKDAY(DATE(A2,1,1)),DATE(A2,1,1),DATE(A2,1,1)-1,DATE(A2,1,1)-2,DATE(A2,1,1)-3,DATE(A2,1,1)-4,DATE(A2,1,1)-5,DATE(A2,1,1)-6)+5+(B2-1)*7

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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