last day (15 days later) » 

16:29
9
A: date -d 'previous Monday" to display the preceding Monday

terdonUse last instead of previous: $ date -d "last Monday" Mon May 6 00:00:00 BST 2019 This is documented in info date, and the specific mention of last is in the "29.6 Day of week items" section (thanks to @Jos and @hobbs for finding it): A number may precede a day of the week item to move fo...

thank you. Where could find the date-string text semantic format? I searched around and around but does not find that.
@Alice what format is that? Please edit your question to clarify or ask a new one.
The documentation which state to use 'last, next or those"
@Alice I don't understand what you are asking for. The documentation is in man date and info date. I admit I can't find a mention of last explicitly though. I have no idea what you mean by "date-string text semantic format".
Jos
Jos
@terdon I believe Alice is looking for what can be specified as the input string for the date command, which is in fact documented in info date but is much more accessble here: gnu.org/software/coreutils/manual/html_node/…
16:29
@Jos yeah, that's just the info page but there's no mention of last there for some reason.
So @Alice's question remains unanswered. If there is no documentation of "last", how is a clueless newbie supposed to Read The Fine Manual and know to use this word? The use of "last" is ambiguous. On May 9th, 2019, does it mean May 6, Apr 29, or May 27? One could easily say that May 6 is "this Monday" and Apr 29 is "last Monday", and it's equally true that the last Monday in May this year is the 27th. "Previous" does not allow that third interpretation.
@MontyHarder I'm not sure what your point is. If you think that the manual should be corrected (and it should), please report it as a bug. There isn't much I can do about it. As for its being ambiguous, there you lost me completely. Why in the world would "last monday" point to Apr 29, two weeks ago? Last Monday is last Monday, the previous Monday, May 6th. There's nothing ambiguous about that. None of the other interpretations make sense in this context. That's an issue of English though and not of the GNU date command.
@terdon I actually have two points. One is that Alice is not the ambiguous one here. Apr 29 isn't two weeks ago. Last week is "one week ago". And Apr 29 is the Monday of last week, which makes it "last Monday" to a lot of people. If you're going to pick one of the three meanings, it's very important to document which one.
@MontyHarder I don't know why you're telling me all this. Please take it up with the developers of GNU date. I just use the thing, I don't maintain it.
@terdon because you're the one who said "I don't understand what you're asking for". Don't ask for an explanation if you're not willing to receive it without attacking someone.
@Alice (and Monty Harder): It's documented in the "Day of week items" section of that info doc, not (as you might expect) "Relative items in date strings".
16:29
@hobbs wait, what? I didn't understand what Alice was saying in her comment, no. But Jos explained it. Then Monty here went off on a tangent about whether or not "last" is ambiguous, something I have no control over. And I was trying to get Monty to go tell the devs who can actually do something about it instead of me. The explanation was received 2 hours ago. And I didn't mean to attack anyone, sorry if it came across that way. All I wanted was to stop being told how bad something I cannot change is.
@terdon okay. I think it was just commentary on the need to identify the exact rules in use, preferably by linking a good doc, to make this a good answer. Because of the ambiguity in English we can't rely on the "ordinary meaning of the phrase", we have to pin down what it means to coreutils. It's not a request for you to fix coreutils.
@hobbs yes indeed. The only reason I didn't add this information is because I couldn't find it. I did check man and info but it wasn't where I expected so I posted the answer based on my personal knowledge instead. Now that you have found the reference, please edit it into the answer! That would be great!
@hobbs I searched English SE to see if there's a well-defined meaning of "Last Monday" and the accepted answer at english.stackexchange.com/questions/57228/… was that it isn't.
JoL
JoL
@terdon "but there's no mention of last there" -- It's there. In the subpage "General date syntax" it says: "the word ‘last’ stands for -1"
@JoL please see updated answer
16:42
Oh wow, I only just recognized your avatar @MontyHarder! Great movie!
@JoL Now try this:

printf 'first thursday\nsecond thursday\n' | date -f -
Thu May 16 00:00:00 CDT 2019
Thu May 9 00:00:01 CDT 2019
 
1 hour later…
JoL
JoL
17:51
@MontyHarder From the same link: "‘first’ and ‘next’ both stand for 1. Because the word ‘second’ stands for the unit of time there is no way to write the ordinal number 2"
 
1 hour later…
19:06
"2nd"
 
2 hours later…
JoL
JoL
20:44
@MontyHarder "2" is shorter: date -d '2 thursday'. You can also write 2nd like this, if you really want: date -d '2(nd) thursday'.

last day (15 days later) »