Date Command Gives Wrong Week Number for Dec 31
up vote
15
down vote
favorite
When I try to get the week number for Dec 31, it returns 1. When I get the week number for Dec 30, I get 52 --- which is what I would expect. The day Monday is correct. This is on a RPI running Ubuntu.
$ date -d "2018-12-30T1:58:55" +"%V%a"
52Sun
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
Same issue without time string
$ date -d "2018-12-31" +"%V%a"
01Mon
linux command-line date
New contributor
add a comment |
up vote
15
down vote
favorite
When I try to get the week number for Dec 31, it returns 1. When I get the week number for Dec 30, I get 52 --- which is what I would expect. The day Monday is correct. This is on a RPI running Ubuntu.
$ date -d "2018-12-30T1:58:55" +"%V%a"
52Sun
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
Same issue without time string
$ date -d "2018-12-31" +"%V%a"
01Mon
linux command-line date
New contributor
4
"Date Command Gives Wrong Week Number for Dec 31" – "Wrong" according to which specification? Is the specification you are using the same one that the manual fordate
says it is using?
– Jörg W Mittag
16 hours ago
2
Excel week number inconsistent results, Excel weeknum function returns wrong week, UI calendar shows wrong week number
– phuclv
9 hours ago
1
You might be interested in Why does the MonthCalendar control show the wrong week numbers in Romania? The blog post is about Windows, but the issue being discussed is general (and seems to be the same as what you are encountering).
– a CVn
5 hours ago
add a comment |
up vote
15
down vote
favorite
up vote
15
down vote
favorite
When I try to get the week number for Dec 31, it returns 1. When I get the week number for Dec 30, I get 52 --- which is what I would expect. The day Monday is correct. This is on a RPI running Ubuntu.
$ date -d "2018-12-30T1:58:55" +"%V%a"
52Sun
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
Same issue without time string
$ date -d "2018-12-31" +"%V%a"
01Mon
linux command-line date
New contributor
When I try to get the week number for Dec 31, it returns 1. When I get the week number for Dec 30, I get 52 --- which is what I would expect. The day Monday is correct. This is on a RPI running Ubuntu.
$ date -d "2018-12-30T1:58:55" +"%V%a"
52Sun
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
Same issue without time string
$ date -d "2018-12-31" +"%V%a"
01Mon
linux command-line date
linux command-line date
New contributor
New contributor
edited 19 hours ago
Jesse_b
11k22762
11k22762
New contributor
asked 19 hours ago
George Shafer
853
853
New contributor
New contributor
4
"Date Command Gives Wrong Week Number for Dec 31" – "Wrong" according to which specification? Is the specification you are using the same one that the manual fordate
says it is using?
– Jörg W Mittag
16 hours ago
2
Excel week number inconsistent results, Excel weeknum function returns wrong week, UI calendar shows wrong week number
– phuclv
9 hours ago
1
You might be interested in Why does the MonthCalendar control show the wrong week numbers in Romania? The blog post is about Windows, but the issue being discussed is general (and seems to be the same as what you are encountering).
– a CVn
5 hours ago
add a comment |
4
"Date Command Gives Wrong Week Number for Dec 31" – "Wrong" according to which specification? Is the specification you are using the same one that the manual fordate
says it is using?
– Jörg W Mittag
16 hours ago
2
Excel week number inconsistent results, Excel weeknum function returns wrong week, UI calendar shows wrong week number
– phuclv
9 hours ago
1
You might be interested in Why does the MonthCalendar control show the wrong week numbers in Romania? The blog post is about Windows, but the issue being discussed is general (and seems to be the same as what you are encountering).
– a CVn
5 hours ago
4
4
"Date Command Gives Wrong Week Number for Dec 31" – "Wrong" according to which specification? Is the specification you are using the same one that the manual for
date
says it is using?– Jörg W Mittag
16 hours ago
"Date Command Gives Wrong Week Number for Dec 31" – "Wrong" according to which specification? Is the specification you are using the same one that the manual for
date
says it is using?– Jörg W Mittag
16 hours ago
2
2
Excel week number inconsistent results, Excel weeknum function returns wrong week, UI calendar shows wrong week number
– phuclv
9 hours ago
Excel week number inconsistent results, Excel weeknum function returns wrong week, UI calendar shows wrong week number
– phuclv
9 hours ago
1
1
You might be interested in Why does the MonthCalendar control show the wrong week numbers in Romania? The blog post is about Windows, but the issue being discussed is general (and seems to be the same as what you are encountering).
– a CVn
5 hours ago
You might be interested in Why does the MonthCalendar control show the wrong week numbers in Romania? The blog post is about Windows, but the issue being discussed is general (and seems to be the same as what you are encountering).
– a CVn
5 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
33
down vote
This is giving you the ISO week which starts on Monday's
The ISO week date system is effectively a leap week calendar system that is part of the ISO 8601 date and time standard issued by the International Organization for Standardization (ISO) since 1988 (last revised in 2004) and, before that, it was defined in ISO (R) 2015 since 1971. It is used (mainly) in government and business for fiscal years, as well as in timekeeping. This was previously known as "Industrial date coding". The system specifies a week year atop the Gregorian calendar by defining a notation for ordinal weeks of the year.
An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. The extra week is sometimes referred to as a leap week, although ISO 8601 does not use this term.
Weeks start with Monday. Each week's year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January. ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January.
If you want to show 12/31 as week 52 you should use %U
which does not use the ISO standard:
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
$ date -d "2018-12-31T1:58:55" +"%U%a"
52Mon
add a comment |
up vote
2
down vote
The definition of the week number is different between Europe and the USA, probably ISO versus ANSI standards. This may be related to a week being Sunday--Saturday or Monday--Sunday, and this again may be related to the Jewish versus Christian definition of the Lord's Day (Sabbath vs Sunday).
For Europe, week number 1 contains the first Thursday in January, and thus it contains a minimum of 4 days (i.e. a majority) belonging to the new year (Thu-Fri-Sat-Sun).
Anyway, in such years when ALL (!!) week numbers are +/- 1 different between Europe and the USA this gives great fun with setting schedules in multi-national companies. :-)
New contributor
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
33
down vote
This is giving you the ISO week which starts on Monday's
The ISO week date system is effectively a leap week calendar system that is part of the ISO 8601 date and time standard issued by the International Organization for Standardization (ISO) since 1988 (last revised in 2004) and, before that, it was defined in ISO (R) 2015 since 1971. It is used (mainly) in government and business for fiscal years, as well as in timekeeping. This was previously known as "Industrial date coding". The system specifies a week year atop the Gregorian calendar by defining a notation for ordinal weeks of the year.
An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. The extra week is sometimes referred to as a leap week, although ISO 8601 does not use this term.
Weeks start with Monday. Each week's year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January. ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January.
If you want to show 12/31 as week 52 you should use %U
which does not use the ISO standard:
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
$ date -d "2018-12-31T1:58:55" +"%U%a"
52Mon
add a comment |
up vote
33
down vote
This is giving you the ISO week which starts on Monday's
The ISO week date system is effectively a leap week calendar system that is part of the ISO 8601 date and time standard issued by the International Organization for Standardization (ISO) since 1988 (last revised in 2004) and, before that, it was defined in ISO (R) 2015 since 1971. It is used (mainly) in government and business for fiscal years, as well as in timekeeping. This was previously known as "Industrial date coding". The system specifies a week year atop the Gregorian calendar by defining a notation for ordinal weeks of the year.
An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. The extra week is sometimes referred to as a leap week, although ISO 8601 does not use this term.
Weeks start with Monday. Each week's year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January. ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January.
If you want to show 12/31 as week 52 you should use %U
which does not use the ISO standard:
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
$ date -d "2018-12-31T1:58:55" +"%U%a"
52Mon
add a comment |
up vote
33
down vote
up vote
33
down vote
This is giving you the ISO week which starts on Monday's
The ISO week date system is effectively a leap week calendar system that is part of the ISO 8601 date and time standard issued by the International Organization for Standardization (ISO) since 1988 (last revised in 2004) and, before that, it was defined in ISO (R) 2015 since 1971. It is used (mainly) in government and business for fiscal years, as well as in timekeeping. This was previously known as "Industrial date coding". The system specifies a week year atop the Gregorian calendar by defining a notation for ordinal weeks of the year.
An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. The extra week is sometimes referred to as a leap week, although ISO 8601 does not use this term.
Weeks start with Monday. Each week's year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January. ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January.
If you want to show 12/31 as week 52 you should use %U
which does not use the ISO standard:
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
$ date -d "2018-12-31T1:58:55" +"%U%a"
52Mon
This is giving you the ISO week which starts on Monday's
The ISO week date system is effectively a leap week calendar system that is part of the ISO 8601 date and time standard issued by the International Organization for Standardization (ISO) since 1988 (last revised in 2004) and, before that, it was defined in ISO (R) 2015 since 1971. It is used (mainly) in government and business for fiscal years, as well as in timekeeping. This was previously known as "Industrial date coding". The system specifies a week year atop the Gregorian calendar by defining a notation for ordinal weeks of the year.
An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. The extra week is sometimes referred to as a leap week, although ISO 8601 does not use this term.
Weeks start with Monday. Each week's year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January. ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January.
If you want to show 12/31 as week 52 you should use %U
which does not use the ISO standard:
$ date -d "2018-12-31T1:58:55" +"%V%a"
01Mon
$ date -d "2018-12-31T1:58:55" +"%U%a"
52Mon
answered 19 hours ago
Jesse_b
11k22762
11k22762
add a comment |
add a comment |
up vote
2
down vote
The definition of the week number is different between Europe and the USA, probably ISO versus ANSI standards. This may be related to a week being Sunday--Saturday or Monday--Sunday, and this again may be related to the Jewish versus Christian definition of the Lord's Day (Sabbath vs Sunday).
For Europe, week number 1 contains the first Thursday in January, and thus it contains a minimum of 4 days (i.e. a majority) belonging to the new year (Thu-Fri-Sat-Sun).
Anyway, in such years when ALL (!!) week numbers are +/- 1 different between Europe and the USA this gives great fun with setting schedules in multi-national companies. :-)
New contributor
add a comment |
up vote
2
down vote
The definition of the week number is different between Europe and the USA, probably ISO versus ANSI standards. This may be related to a week being Sunday--Saturday or Monday--Sunday, and this again may be related to the Jewish versus Christian definition of the Lord's Day (Sabbath vs Sunday).
For Europe, week number 1 contains the first Thursday in January, and thus it contains a minimum of 4 days (i.e. a majority) belonging to the new year (Thu-Fri-Sat-Sun).
Anyway, in such years when ALL (!!) week numbers are +/- 1 different between Europe and the USA this gives great fun with setting schedules in multi-national companies. :-)
New contributor
add a comment |
up vote
2
down vote
up vote
2
down vote
The definition of the week number is different between Europe and the USA, probably ISO versus ANSI standards. This may be related to a week being Sunday--Saturday or Monday--Sunday, and this again may be related to the Jewish versus Christian definition of the Lord's Day (Sabbath vs Sunday).
For Europe, week number 1 contains the first Thursday in January, and thus it contains a minimum of 4 days (i.e. a majority) belonging to the new year (Thu-Fri-Sat-Sun).
Anyway, in such years when ALL (!!) week numbers are +/- 1 different between Europe and the USA this gives great fun with setting schedules in multi-national companies. :-)
New contributor
The definition of the week number is different between Europe and the USA, probably ISO versus ANSI standards. This may be related to a week being Sunday--Saturday or Monday--Sunday, and this again may be related to the Jewish versus Christian definition of the Lord's Day (Sabbath vs Sunday).
For Europe, week number 1 contains the first Thursday in January, and thus it contains a minimum of 4 days (i.e. a majority) belonging to the new year (Thu-Fri-Sat-Sun).
Anyway, in such years when ALL (!!) week numbers are +/- 1 different between Europe and the USA this gives great fun with setting schedules in multi-national companies. :-)
New contributor
New contributor
answered 3 hours ago
StessenJ
1211
1211
New contributor
New contributor
add a comment |
add a comment |
George Shafer is a new contributor. Be nice, and check out our Code of Conduct.
George Shafer is a new contributor. Be nice, and check out our Code of Conduct.
George Shafer is a new contributor. Be nice, and check out our Code of Conduct.
George Shafer is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482032%2fdate-command-gives-wrong-week-number-for-dec-31%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
"Date Command Gives Wrong Week Number for Dec 31" – "Wrong" according to which specification? Is the specification you are using the same one that the manual for
date
says it is using?– Jörg W Mittag
16 hours ago
2
Excel week number inconsistent results, Excel weeknum function returns wrong week, UI calendar shows wrong week number
– phuclv
9 hours ago
1
You might be interested in Why does the MonthCalendar control show the wrong week numbers in Romania? The blog post is about Windows, but the issue being discussed is general (and seems to be the same as what you are encountering).
– a CVn
5 hours ago