简体   繁体   中英

YEAR() fitting to WEEKNUM(…,21) in Excel

I'm looking for a way to specify return 2015 for a date within this week, but in Calendar Year 2014. This current week according to the Thursday system is Week 01/2015. But the Year function will still return 2014.

Something like: IF(AND(WEEKNUM(TODAY(),21)=52,WEEKNUM(TODAY()+7,21)<>53),YEAR(TODAY())+1,YEAR(TODAY())

but a little bit more reliable and elegant.

Anybody got something?

Happy Happy

Ben-san

The "Year" of the week is determined by the year of the Thursday of that week (assuming ISO week numbers) so you can just find the Thursday and then get the year of that date, ie for any date in A1

=YEAR(A1-WEEKDAY(A1,3)+3)

or, similarly, for today's date

=YEAR(TODAY()-WEEKDAY(TODAY(),3)+3)

This works for any date in any year.......and might put days in Jan in the previous year also, eg 3rd Jan 2016 is in the last week of 2015

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