1

IN last topic: date calculation: add n days

i want to change \DueDate{2019/10/26}{15} to new format: \DueDate{26/10/2019}{15}

Thank in advance

Code:

\documentclass[10pt]{article}
\usepackage[calc,datesep=/]{datetime2}
\newcount\daycount
\newcommand{\DueDate}[2]{%
  \DTMsavedate{ShootDate}{#1}%
  \DTMsaveddateoffsettojulianday{ShootDate}{#2}\daycount
  \DTMsavejulianday{ShootDate}{\number\daycount}%
  \DTMusedate{ShootDate}%
}

\begin{document}

26/10/2019 + 15 day = \DueDate{26/10/2019}{15}

14/11/2019 + 30 day = \DueDate{2019-11-14}{30}

05/03/2020 + 45 day = \DueDate{2020-03-05}{45}
\end{document}

1 Answer 1

1

How about this option - parse dates for \DueDate{<day>/<month>/<year>}{<adv>} using the prescribed format and uses advdate to move the date forward <adv> days:

enter image description here

\documentclass{article}

\usepackage{advdate}

\makeatletter
\def\settoday#1/#2/#3\relax{\ThisDay{#1}\ThisMonth{#2}\ThisYear{#3}}
\newcommand{\DueDate}[2]{%
  \expandafter\settoday#1\relax
  \AdvanceDate[#2]%
  \number\day/\number\month/\number\year
  %\two@digits{\day}/\two@digits{\month}/\number\year% Two digits for month/day
}
\makeatother

\begin{document}

26/10/2019 + 15 day = \DueDate{26/10/2019}{15}

14/11/2019 + 30 day = \DueDate{14/11/2019}{30}

05/03/2020 + 45 day = \DueDate{5/3/2020}{45}

11/12/2013 + 1 day = \DueDate{11/12/2013}{1}

\end{document}

You can use the "two digit" format, if needed:

enter image description here

2
  • Can you edit format of output to day/month/year ? thanks
    – latexforti
    Oct 27, 2019 at 4:38
  • 1
    @latexforti: Updated the answer.
    – Werner
    Oct 27, 2019 at 4:58

You must log in to answer this question.

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