简体   繁体   中英

“Year” and “Weeknum” Function in excel 2013

I have a problem with the " Year " and " Weeknum " functions in excel 2013 .

I tried the formula below using the functions:

=YEAR(RC[1])&"_WW_"&IF(Weeknum(RC[1])<10,"0"&Weeknum(RC[1]),WeekNum(RC[1]))

On some dates, I get back " #VALUE! " and And the correct field for other dates...

for example: for the date " 11/30/2013 20:15:00 ", I'm getting " #VALUE " for the date " 12/07/2013 20:15:00 ", I'm getting " 2013_WW_28 "

when evaluating formula, both " Year " and " weeknum " return "#VALUE!". and On both of the examples, the date field is set as " General " (trying playing with it and change it to " long date " or " short date "' and it didn't work...)

If the format is general in this context that means your "dates" are text values

The only dates that are deemed valid are those where day <= 12......and those are being interpreted the wrong way round hence wrong WEEKNUM.

You can try changing to valid dates with "text to columns" but you may lose the times, is that a problem?

Select date column then.....

Use Data > Text to Columns > "Fixed width" > Next > at step 2 insert a line between times and dates > Next > at step 3, with date column selected, under "column data format" choose "date" and the source format (MDY) > OK

This should convert to valid date format for your region and formula should work as expected

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