4
\documentclass{article}
\usepackage{ifthen}

\newcounter{theyear}
\setcounter{theyear}{\number\year}
\newcommand{\shorttoday}
{
\ifthenelse{\number\month<5}{May, }{\ifthenelse{\number\month <8}{August, }
{\addtocounter{theyear}{1} January, }}\value{theyear}}
\begin{document}

%\number\month
\shorttoday

\end{document}

Why this result?

Missing number, treated as zero
<to be read again>
                   \par
l.14 
Sveinung
  • 20,355
  • 3
    \value{theyear} doesn't print the value; for that you should use \thetheyear. All \number tokens you're using are redundant. – egreg Mar 10 '16 at 15:14

1 Answers1

2

There is no problem with \ifthenelse. You have a misplaced \value{theyear}, which should be \thetheyear, for printing the value.

Why does a “Missing number” error shows up? You have to know that \value{theyear} just produces the symbolic name of the counter, not its value; when TeX finds a counter name and it is not looking for a number, it starts an assignment, but it finds no number to assign to the counter.

\documentclass{article}
\usepackage{ifthen}

\newcounter{theyear}
\setcounter{theyear}{\year}
\newcommand{\shorttoday}{%
  \ifthenelse{\month<5}%
    {May, }%
    {\ifthenelse{\month <8}%
      {August, }%
      {\addtocounter{theyear}{1}January, }%
    }%
  \thetheyear
}
\begin{document}

\shorttoday

\end{document}

I reformatted the code, removing all spurious spaces you had and also the redundant \number tokens.

egreg
  • 1,121,712