11

I usually generate a report for the previous day (as I imagine isn't all too uncommon) and so I'd like to date it with yesterday's date instead of today. Currently I have:

\title{foo}
\date{\today}

But I can't seem to find a \yesterday or anything beyond simple formatting in packages like datetime - is there a simple way to get this?

16

There's an old but working package: advdate:

\documentclass{article}

\usepackage{advdate}
\title{foo}
\date{\AdvanceDate[-1]\today}  % Go back one day

\begin{document}
\maketitle
Today is \today\ but yesterday was {\AdvanceDate[-1]\today}

but we are still \today



\end{document}

enter image description here

Edit:

With \yesterday and \tomorrow commands (note the internal grouping)

\documentclass{article}

\usepackage{advdate}

\newcommand{\yesterday}{{\AdvanceDate[-1]\today}}

\newcommand{\tomorrow}{{\AdvanceDate[1]\today}}

\title{foo}
\date{\yesterday}



\begin{document}
\maketitle
\noindent Today is \today\ but yesterday was \yesterday, tomorrow will be \tomorrow,
but we are still on \today.

\end{document}

enter image description here

|improve this answer|||||
  • This worked! Thanks. I tried googling for how to do this and was surprised not to find something given how common it probably is to do this. – Palace Chan Oct 14 '15 at 14:31
10
\documentclass{article}
\advance\day by -1
\begin{document}
\today
\end{document}

enter image description here

(created on October 14, 2015)

(But it won't work on the first of a month ... so advdate or a similar package from http://www.ctan.org/topic/date-time is better ;-))

|improve this answer|||||
7

Another possibility is to use datetime2 with the calc option:

\documentclass{article}

\usepackage[calc]{datetime2}

\title{Sample}
\author{Me}
\date{\DTMdate{\year-\month-\day+-1}}

\begin{document}
\maketitle

\end{document}
|improve this answer|||||
  • 1
    Oh the overloaded - is so nicely confusing :-) – yo' Oct 14 '15 at 15:19
  • @yo' Yes, I forgot on my first attempt that I needed the + before -1. That's the pgfcalendar syntax which datetime2-calc uses behind the scenes :-) – Nicola Talbot Oct 14 '15 at 15:33

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