I am working on a weekly teaching plan. I need the start date and end date of each week. For example, week 30 I want 7/25 - 7/29, week 31 I want 1/8 - 5/8. I don't want to do this manually, because it takes a long time. Is there a convenient way to get the first and last day of a week? Thank you.enter image description here

  • 1
    If you know Python there's always the option of using e.g. pythontex and its datetime module
    – user202729
    Commented Jul 21, 2022 at 5:44
  • Maybe look for termcal/datetime2 package
    – user202729
    Commented Jul 21, 2022 at 5:45
  • Unfortunately I don't know python. Commented Jul 21, 2022 at 5:50
  • 2
    I suggest checking in PGF manual ctan.org/pkg/pgf Section 47 Calendar Library for the calendar library of TikZ, and Section 89 Date and Calendar Utility Macros for the package pgfcalendar. This package can be used independently of pgf.
    – Black Mild
    Commented Jul 21, 2022 at 6:06
  • Thank you, I will read it. Commented Jul 21, 2022 at 6:53

1 Answer 1


Specifying the first day of the first week manually

You can use pgfcalendar to store the first day of your first week in a LaTeX counter and use that later as the base for an offset.

With \setStartDate you set the first day of your first week and the \getDateOfWeek{<week>}{<offset>} will define \Year, \Month, \Day with the date that is in the <week>th week with an additional <offset>.

For example:


sets the first week to start on October 10th, 2022.



you'll get October 14th and with


you'll get October 17th in \Month and \Day.


\newcommand*{\setStartDate}[1]{% for week 1
    \advance\@tempcnta by \c@myStartDate
\foreach \week in {1,...,52}{
  Week \week\ goes from \getDateOfWeek{\week}{0}\Month/\Day\ to


enter image description here

Using the actual week numbers of the years.

With the pgfcalendar-ext package of my tikz-ext package which incorporates another answer of mine and uses the week numbering according to ISO 8601 which mainly means that a new week starts on Monday.

Here's a solution with

  {<year>}{<month>}{<day>}{<offset year>}{<offset month>}{<offset day>}

which defines six macros (the argments on the second line) for you which contain

  • the first day of <week> of <year> and
  • the day that's <offset> after the first day of <week> of <year>.

The <year> argument is optionally, the default is the current year.


  % #1 = year (defaults to current year)
  % #2 = week number, #3 = offset
  % #4/#5/#6 = start year/month/day
  % #7/#8/#9 = end year/month/day
      % This is the last week of the previous year
  \begin{tabular}[t]{@{}l@{}}Week #2:\\

Time & Content & Note \\\midrule
\weekCell{1} & Content 1 & Note 1 \\
\weekCell{2} & Content 2 & Note 2 \\
\dots & \dots & \dots \\\bottomrule


enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .