Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

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?

Thanks for your help.

share|improve this question

marked as duplicate by Manuel, Guido, Christian Hupfer, Masroor, Adam Liter Jul 16 at 3:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
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 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 at 8:25
    
    
@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 at 9:27

2 Answers 2

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}%

\usepackage{advdate}

\newcommand{\advanceday}[1][14]{%
\begingroup
\AdvanceDate[#1]%
\today%
\endgroup
}%

\newcommand{\evenmoreadvanceday}[1][28]{%
\advanceday[#1]%
}%


\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}

enter image description here

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

A variation of advdate:

\documentclass{article}
\usepackage{xstring}% Needed for \IfStrEqCase
\usepackage{datenumber}% Date formatting
\usepackage{advdate}% Needed for \AdvanceDate
\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
    \AdvanceDate[\value{dateOffset}]% Advance to specified day
    \today% Print specified date
    \AdvanceDate[-\value{dateOffset}]% Restore current day
    is #1day 2 weeks later% debug output
}

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

enter image description here

share|improve this answer
1  
This is interesting, but if I understood correctly your code, you can only compute what date is next Monday, right? –  Clément Jul 9 at 17:00
    
After 2 weeks (14 days) –  subham soni Jul 9 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 at 17:49

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