I would like to get the date of the monday of the first week of a year from only the year
The purpose is a week planner where I put one week on each page and as most of the years first weeks monday is in the last year, so I have to calculate that date
I already thought about some kind of \ifdate{Monday}.... with many ifs to get a 'stupid' solution, but I would like an 'efficient' solution and somehow I just can't get into latex very well and I still don't understand what structures are used in this language and how that whole thing works as it is very abstract

  • Just to get it clear, you are here talking about a so-called “ISO week”, where the rule is that a week (which is Monday–Sunday) belongs to the year which has the majority of the week's days, or equivalently, the year of the week's Thursday? – Harald Hanche-Olsen Jan 7 at 23:02
  • Do you specifically need that Monday, or the week day of the 1st January? – Skillmon Jan 7 at 23:04
  • thanks for asking! no, I want to get the monday of the week, even if the 01-01 is a sunday, so in that case I would like to get the 12-26 of the previous year – Marcel H. Jan 7 at 23:05
  • @marcoPolio do you know any efficient algorithm one could implement, that does that? – Skillmon Jan 7 at 23:06
  • @Skillmon no not really, it doesn't really have to be efficient, I just would like to have a less stupid approach than my \ifdate{Monday}... – Marcel H. Jan 7 at 23:09

pgfcalendar has methods to calculate the weekday of a given date. The following uses it to define \MondaysDateIs as the date of the first weeks Monday of a year given to \GetMondaysDate:



    \or % 1
      \edef\MondaysDateIs{\the\YearCount -12-31}%
    \or % 2
      \edef\MondaysDateIs{\the\YearCount -12-30}%
    \or % 3
      \edef\MondaysDateIs{\the\YearCount -12-29}%
    \or % 4
      \edef\MondaysDateIs{\the\YearCount -12-28}%
    \or % 5
      \edef\MondaysDateIs{\the\YearCount -12-27}%
    \or % 6
      \edef\MondaysDateIs{\the\YearCount -12-26}%


enter image description here

  • weell, that's kind of the approach that I thought of, but it looks a lot better than what I would have done! thanks a lot, that solves my problem completely :) – Marcel H. Jan 7 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.