1

I got a question regarding the usage of the datetime2 package. I want to set some due date and to define a certain date such as \paperdate which is either \today when it's before the due date or the due date itself. I tried this based on an example from the package's documentation:

\documentclass{article}
\usepackage[useregional, calc]{datetime2}

\begin{document}

\DTMsavedate{duedate}{2023-04-30} \DTMifdate {\today} {at most= \DTMfetchyear{duedate}-\DTMfetchmonth{duedate}-\DTMfetchday{duedate}} {\newcommand\paperdate{\today}}{\newcommand\paperdate{\DTMusedate{duedate}}}

\end{document}

However, this code gives me the following error: Package datetime2-calc Error: Unknown date `2023-04-23'.

Would anyone know a workaround? Thanks in advance for your help!

pahohu
  • 229

1 Answers1

1

I found a solution myself! Based on the discussion How to calculate previous month from \today using datetime2? :

\usepackage[useregional, calc]{datetime2}

\begin{document} \DTMsavenow{today}

\DTMsavedate{duedate}{2023-04-30} \DTMifdate {today} {at most= \DTMfetchyear{duedate}-\DTMfetchmonth{duedate}-\DTMfetchday{duedate}} {\newcommand\paperdate{\today}}{\newcommand\paperdate{\DTMusedate{duedate}}}

\end{document}

pahohu
  • 229