# Advancing \today by x days [duplicate]

New LaTex user here, hoping you can help me.

I am drafting a letter, the submission date of which I do not yet know. For this reason I am dating it using \today. However, in the text of the letter, I would like to specify a date two weeks in advance of \today. In other words, there is an [advance date] and an [advance date II], the latter specifying a date 14 days after the former.

I found the advdate package but, unless I am mistaken, it doesn't allow for setting two individual hypothetical dates. Is there a non-complicated way of implementing this?

-

## marked as duplicate by Manuel, Guido, Christian Hupfer, Masroor, Adam LiterJul 16 '14 at 3:57

Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Christian Hupfer Jul 9 '14 at 15:45
@percusse: The question you linked is about a \tomorrow command, but this post is about a \fortnight or a double \fortnight command ;-). It is related, for sure, but not a duplicate. – Christian Hupfer Jul 11 '14 at 8:25
– Nicola Talbot Jul 11 '14 at 9:17
@ChristianHupfer You can add or subtract as many as you want instead of +1. It's just the name of the macro it is not limited to tomorrow per se – percusse Jul 11 '14 at 9:27

The package advdate provides the command \AdvanceDate[] with an optional argument, defaulting to 1 (day). However, it changes the date output by \today. This can be prevented by using a new command, say \advanceday and using a group inside, such that registers are changed only locally, this is shown in the output, where the second call to \today (after the first call to \advanceday still shows the current date (9th of July 2014), so it is not affected by \advanceday outside!

I used an optional argument to \advanceday, defaulting to 14 days and added a command \evenmoreadvanceday, with optional argument defaulting to 28 days, but actually, \evenmoreadvanceday is redundant, since \advancedays[28] does the same job. It is rather meant to make the second date more outstanding in the code.

You can change the output format of \today by usage of datetime package and its various options/commands (not done in here)

\documentclass{article}%

\begingroup
\today%
\endgroup
}%

}%

\begin{document}

Today is \today~and in 14 days it is \advanceday, but today is still \today~and in 28 days it is \evenmoreadvanceday%

\end{document}


-
Thank you very much @Christian Hupfer! I'm not sure how or why, but it works! – foucalt Jul 9 '14 at 16:15
@foucalt: If you have questions about the code, just ask ;-) – Christian Hupfer Jul 9 '14 at 16:35

A variation of advdate:

\documentclass{article}
\usepackage{xstring}% Needed for \IfStrEqCase
\usepackage{datenumber}% Date formatting
\usepackage{pgf}% For math

\newcounter{dateOffset}%
\newcommand*{\SetDateOffsetForNext}[1]{%
\pgfmathsetcounter{dateOffset}{7-int(\the\value{datedayname})}% Initialize
\IfStrEqCase{#1}{%
{mon}{\pgfmathsetcounter{dateOffset}{int(mod(\the\value{dateOffset}+8,14))}}%
}[\PackageError{\SetDateOffsetForNext}{Do not know "#1" as day of week}{}]%
\IfEq{\the\value{dateOffset}}{0}{\pgfmathsetcounter{dateOffset}{7}}{}%
}%

\newcommand*{\PrintDateForNext}[1]{%
\SetDateOffsetForNext{#1}% Determine date offset
\today% Print specified date
is #1day 2 weeks later% debug output
}

\begin{document}
Today is \today\par
\PrintDateForNext{mon}\par
\end{document}


-
This is interesting, but if I understood correctly your code, you can only compute what date is next Monday, right? – Clément Jul 9 '14 at 17:00
After 2 weeks (14 days) – subham soni Jul 9 '14 at 17:01
I appreciate other solutions too, but I do not understand why you restricted your solution to Mondays? (Using \PrintDateForNext{tue}` fails with compilation error, for example) The specific day of week is basically completely irrelevant. Only the relative day shift of 14 (or whatever) days is of importance. – Christian Hupfer Jul 9 '14 at 17:49
@subhamsoni: It is customary to provide a link to where you got the original code from: Insert relative date and time specifications?. – Peter Grill Jan 9 at 6:11