Make a CV auto updating

I would like to create a code to insert in my CV that make it auto update.

The hypotetic sentence is this one:

"Engineer with twenty experience years", where twenty is generated by, e.g., \startyear{1997}.

I have written this code:

\documentclass{article}
\usepackage{calculator}

\newcommand{\startyear}[1]{\SUBTRACT{\the\year}{1997}{\sol}\sol}

\begin{document}
Engineer with \startyear{1997} experience years.
\end{document}


that returns:

*

Engineer with 20 experience years.

*

But I would like the number (20) in text.

• after a quick google: the fmtcountpackage might be helpful – daleif Aug 28 '17 at 10:13
• No need to use the calculator package here. \newcommand{\startyear}[1]{\the\numexpr\year-#1} – user31729 Aug 28 '17 at 10:25
• And with fmtcount as @daleif suggested: \newcommand{\startyear}[1]{\numberstringnum{\numexpr\year-#1}} – user31729 Aug 28 '17 at 10:29
• With \usepackage{fmtcount} and \newcommand{\startyear}[1]{\numberstringnum{\numexpr\year-#1‌​}} in the preamble, I obtain the output: "Engineer with twenty experience years.", but with the error: "Missing = inserted for \ifnum. Engineer with \startyear{1997}" in the line where I use \startyear{1997}. – Giacomo Alessandroni Aug 28 '17 at 14:00
• Isn't this nearly a duplicate of tex.stackexchange.com/questions/28326/…? – Fritz Aug 28 '17 at 16:11

The calculation is pretty easy with \the\numexpr\year-#1 where #1 is considered to hold the number of the starting year.

This is fed into \numberstringnum which 'translates' the number into the number word, i.e. 1 would become one etc.

\documentclass{article}

\usepackage{fmtcount}

\usepackage{pgffor}

\newcommand{\startyear}[1]{\numberstringnum{\the\numexpr\year-#1}}

\begin{document}
\foreach \x in {1900,...,\the\year} {
Engineer with \startyear{\x}\ experience years.

}
\end{document}


• Thanks. I confirm that the code compile with and without the the command in newcommand and in \foreach. – Giacomo Alessandroni Aug 29 '17 at 9:10