General ⇒ How to store the date
How to store the date
This is my first post to this forum and first of all I would like to wish all of you a Happy New Year.
Now, I have a very basic problem i latex:
My code:
\documentclass{article}
\usepackage{datetime}
\usepackage{advdate}
\begin{document}
\newdate{my_date}{\day}{\month}{\year}
\displaydate{my_date} \\
\AdvanceDate[5]
\displaydate{my_date}
\end{document}
Executed today produces:
Monday 3rd January, 2011
Saturday 8th January, 2011
I would like to store \today as a constant and be able to reference to the entry further in the document but it seems that \AdvanceDate modifies \today and my_date does not store the date before modification but a reference.
In other words, how can prevent system to change my_date?
Any suggestions appreciate.
Regards,
Gsks
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
How to store the date
Code: Select all
\documentclass{article}
\usepackage{datetime}
\usepackage{advdate}
\begin{document}
\noindent%
\newdate{my_date}{\day}{\month}{\year}%
\displaydate{my_date} \\
\newsavebox{\constantdate}\savebox{\constantdate}{\displaydate{my_date}}
\AdvanceDate[5]
\displaydate{my_date}\\
\usebox{\constantdate}
\end{document}
How to store the date
I modified a little the code above to store only monthname and added check condition.
Code: Select all
\documentclass{article}
\usepackage{datetime}
\usepackage{advdate}
\usepackage{ifthen}
\begin{document}
\noindent
\newsavebox{\mymonth}\savebox{\mymonth}{\monthname}
\AdvanceDate[5] \\
\ifthenelse{\equal{\usebox{\mymonth}}{\monthname}}{Dates in the same month.}{Different months: \usebox{\mymonth} vs \monthname.}
\AdvanceDate[30] \\
\ifthenelse{\equal{\usebox{\mymonth}}{\monthname}}{Dates in the same month.}{Different months: \usebox{\mymonth} vs \monthname.}
\end{document}
Different months: January vs January.
Different monthe: January vs February.
If I use \the\months instead of \monthname the result is also false.
Why? I am confused

Regards,
gsks
- Attachments
-
- wynik.jpg (14.56 KiB) Viewed 3512 times
How to store the date
Code: Select all
\documentclass{article}
\usepackage{datetime}
\usepackage{advdate}
\begin{document}
\edef\mymonth{\number\month}
\AdvanceDate[5]
\ifnum\month=\mymonth
Same month.
\else
Different month: \monthname[\mymonth] vs \monthname.
\fi
\AdvanceDate[30]
\ifnum\month=\mymonth
Same month.
\else
Different month: \monthname[\mymonth] vs \monthname.
\fi
\end{document}
Nicola Talbot
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/