TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to have an automatic date in a table. Automatic date means I'd like to specify a start date which is shown in the first row of the table and every additional row shows appropriate next day.

I've already implemented a newcommand for the appropriate row. What I need now is a way to increase a specified date by a counter value.

Here are my commands:

    \section*{Tagesberichte Woche #1}
    \section*{Wochenbericht #1}

    \arabic{weekCounter}\stepcounter{weekCounter} & #1 \\ \hline

I'd like to replace \arabic{weekCounter} with the corresponding date which has to be specified somehow in the parameter list of the command.

Do you know how to achieve this?

share|improve this question

migrated from stackoverflow.com Nov 12 '12 at 15:11

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Nov 12 '12 at 15:15
up vote 5 down vote accepted

You can use advdate package to change current date, datenumber and datetime packages for date formatting.


\usepackage{advdate}    % Advancing/saving dates
\usepackage{datetime}   % Dates formatting
\usepackage{datenumber} % Counters for dates

    \SaveDate    % Saves current date (advdate macro)
    \SetDate[#1] % Sets custom date   (advdate macro)
    \setdate{\the\year}{\the\month}{\the\day} % Saves custom date to 
                                              % predefined counter from datenumber
    \SetDate     % Restores current date (advdate macro)

    \section*{Tagesberichte Woche #2}
    \section*{Wochenbericht #2}

    \twodigit{\thedateday}.\twodigit{\thedatemonth}.{\thedateyear} % Prints it in custom formatting
    %\datedate                                                     % For default format use \datedate
    \nextdate % Goes to the next day
    & #1 \\




It shows:

enter image description here

share|improve this answer
After removing \AdvanceDate[-1] it's working like a charm. I don't actually see the reason to do that. Thanks anyway, @redmode! This has helped me a lot. – SeveQ Nov 9 '12 at 18:35
\AdvanceDate[-1] helps starting with exactly the same date you pass to \pweek{}. If you remove this line first date in the table will be next to the date you passed (31.10.2010 in my example). If it is your intention - it's ok. – redmode Nov 10 '12 at 10:36
For some reason I don't see yet it isn't doing that here. It starts with the given date without the \AdvanceDate[-1] instruction. If I add the instruction the first date is one day before the given date. Have you got a clue why? – SeveQ Nov 10 '12 at 16:13
Well, I got the reason of the problem. It's leap year situation. Perhaps you were trying 2012 year - it's ok then. But with 2010, 2002, 1900, 2020 and other it gives a bias equal to the number of leap years between specified and current year. Also I found better solution - I'll edit my answer then. – redmode Nov 10 '12 at 20:22
Yeah, I was trying 2012. Your new solution is again working like a charm. Thank you very much, redmode! – SeveQ Nov 10 '12 at 22:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.