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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a follow up to TeX capacity exceeded while parsing a date string

I want to compare two dates, say today's date and a due date. I have the due date information stored (as number strings) in macros \dueday, \duemonth, and \duemonth. I use the following, from etoolbox package:

\newcommand{\duemonth}{5} % May

    (test {\ifnumcomp{\dueyear}{>}{\year}})
    or (test {\ifnumcomp{\dueyear}{=}{\year}} and test {\ifnumcomp{\duemonth}{>}{\month}})
    or (test {\ifnumcomp{\dueyear}{=}{\year}} and test {\ifnumcomp{\duemonth}{=}{\month}} and test {\ifnumcomp{\dueday}{>}{\day}})
    {Not due yet}
    {Due immediately}

which does work, but I'm looking for a TeX-based solution that, perhaps, can do this more efficiently and without having to use etoolbox.

share|improve this question
You may want to try \pdfstrcmp. – Ali Mehrizi May 6 '12 at 19:21
up vote 6 down vote accepted

This is doable using a series of pure number (\ifnum) tests, where the boolean logic is indicated by an 'outer' test which uses only 0/1:

\def\duemonth{5} % May

\def\notdue{Not due yet}
\def\duenow{Due immediately}

    0 %
      0 %
        0 %
        1 %
  > 0 %

share|improve this answer
A pure TeX-based approach, so I've used plain TeX, hence the \bye. – Joseph Wright May 6 '12 at 19:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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