# Generate schedule planner between two given dates

I am trying to generate a table with the following format:

I am looking for a way to generate the dates given the initial week (In this case Jun 3 - 7)

I tried using the package datenumber but I am only able to set a counter for the initial date (Jun 3, 2019) using \datedate but I obtained the long date format "June 3, 2019".

\usepackage{datenumber}
\newcommand{\dnext}{
\datedate
}
\begin{document}
\setdatenumber{2019}{6}{3}
\begin{tabular}{ccc}
Week  & Dates & Activity\\
1 & \datedate & Some values \\
2 &\pnext & Some values \\
\end{tabular}
\end{document}


My questions are basically the following two:

• Deal with the two counters
• Change the format to the desired one.

I appreciate any suggestion.

If your MWE is really representative if what you are trying to do then I would write a macro that just accepts a comma separated list of "activities" and produces the table from this data. In any case, this would allow you to produce

using

\activities{Walked dog, Ate lunch, Slept}


The trick is to use \docsvlist from the etoolbox package, together with some gratuitous styling via the booktabs package.

With regards to formatting the dates, datenumber defines counters dateday and datemonth for the day and month. So my first thought was that it was enough to wrap these into a macro where you add 4 to the current day:

\newcommand\weekdate{%
\ifcase\value{datemonth}%
\or Jan \or Feb \or Mar \or Apr \or May \or Jun
\or Jul \or Aug \or Sep \or Oct \or Nov \or Dec
\fi
\arabic{dateday}--\the\numexpr\arabic{dateday}+4\relax%
}


Unfortunately, this does not really work because, for example, January does not have 35 days. To take the lengths of the months properly into account you need something like:

\newcommand\weekdate{%
\setmydatebynumber{\the\numexpr\thedatenumber+4}{endofweekyear}{endofweekmonth}{endofweekday}
\ifcase\value{datemonth}%
\or Jan \or Feb \or Mar \or Apr \or May \or Jun
\or Jul \or Aug \or Sep \or Oct \or Nov \or Dec
\fi
\arabic{dateday}--\arabic{endofweekday}%
}


This works but it is very slow to compile. I'm also not sure about writing Jul 29-2 instead of Jul 29-Aug 2, but this seems to be what the OP asks for. It is easy enough to modify the code above to produce Jul 29-Aug 2 if this is what is really wanted.

Here is the full code:

\documentclass{article}
\usepackage{datenumber}
\usepackage{etoolbox}
\usepackage{booktabs}
\newcounter{endofweekday}
\newcounter{endofweekmonth}
\newcounter{endofweekyear}
\newcommand\weekdate{%
\setmydatebynumber{\the\numexpr\thedatenumber+4}{endofweekyear}{endofweekmonth}{endofweekday}
\ifcase\value{datemonth}%
\or Jan \or Feb \or Mar \or Apr \or May \or Jun
\or Jul \or Aug \or Sep \or Oct \or Nov \or Dec
\fi
\arabic{dateday}--\arabic{endofweekday}%
}
\newcounter{activity}
\newcommand\activities[1]{
\renewcommand*\do[1]{%
\stepcounter{activity}%
\setdatebynumber{\thedatenumber}%
\arabic{activity}
& ##1 \\
}
\begin{tabular}{cll}\toprule
Week  & Dates & Activity\\\midrule
\docsvlist{#1}
\bottomrule
\end{tabular}
}

\begin{document}
\setdatenumber{2019}{7}{22}
\activities{Walked dog, Ate lunch, Slept}
\end{document}


You could further embellish this by making the starting date an optional argument to \activities.

• Thanks @Andrew that helps a lot!! – C. Zhihao Jun 1 at 16:40