Problem with \ifthenelse

\documentclass{article}
\usepackage{ifthen}

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

%\number\month
\shorttoday

\end{document}


Why this result?

Missing number, treated as zero
\par
l.14

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

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

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