Right now, 2014-01-06, GNU date 8.4 on CentOS release 6.4, does this:
$ date --date "last week" +"%Y-%V"
2013-01
On the other hand,
$ date --date "last week" +"%Y-%U"
2013-52
which is just marginally better.
Is this really the correct behavior?!
Best Answer
I didn't want to step on @Jordanm's toes by editing up his answer too much but these additional sentences from the ISO week date he cited were also helpful in understanding the issue the OP has highlighted.
excerpt #1 - regarding ISO week dates
excerpt #2 - I also found this bit helpful in understanding the issue
Revisiting the date command
So if you take a look at the
date
man page you'll notice this option in the formatting section.So when you want to print the year along with the ISO week (
%V
) you should really be using the%G
for the year and not the typical%Y
.Example
So when my system's date is reportedly this:
This command will report the ISO week date correctly, as you're looking for: