简体   繁体   English

将日期转换为Wyy(星期数)格式

[英]Convert date to Wyy(week number) Format

I am working with Excel 2010. I wish to convert (for example) cell A1 with today's date in the format 4/10/2017 to a format which is W1715 (W(last two digits of year)(weeknumber)). 我正在使用Excel2010。我希望将(例如)今天日期为4/10/2017的单元格A1转换为W1715(W(年份的后两位数字)(周数))。 It would be great if anyone could help! 如果有人可以帮助,那就太好了! Thanks in Advance. 提前致谢。

If A1 has the Date and is formatted as Date (Excel recognize it as Date) just write in B1 where you want the result: 如果A1具有日期并被格式化为日期(Excel将其识别为日期),则只需在B1中写入您想要的结果:
="W"&VALUE(RIGHT(YEAR(A1),2))&WEEKNUM(A1,1)
Right(Year(A1),2) returns the last 2 digits of the four digit of the Year Right(Year(A1),2)返回年份四位数的最后两位
Weeknum returns the number of the week 1 correspond at 1st week is the week which has the 1st of January week begins on Sunday Weeknum返回第1周对应的第1周是从1月1日开始的周的周

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

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