The command \year gives a number instead of text. How is it done?

As I know, in the command sequence \the\year, \year gives a number, and \the converts it to text.

What I don't understand is, how to make a command that results in a number but not a piece of text representing that number, like the command \year?

In other words, if I want \theXXX to generate "1234" (without quotes), what do I replace XXX with?

-
I'm not quite clear on what you mean here. \the\year yields the year as a number (currently "2011"), while \year may be used directly in places where TeX expects a number. Perhaps you mean the fact that \year is similar in effect to a TeX count register? –  Joseph Wright Nov 21 '11 at 13:24
@JosephWright: Hope the edit helps explaining my question. –  hpsMouse Nov 21 '11 at 13:36
are you thinking of \value{XXX} (where XXX is the counter name)? or are you not actually using latex? –  wasteofspace Nov 21 '11 at 14:07
@Anon: I found \value{XXX} is what I'm looking for. I'm new to latex. Sorry if my question looks stupid. –  hpsMouse Nov 22 '11 at 0:33

This question appears to be more about accessing a counter's value than dates. whlt3 has provided some details on that. Here is an example based on What is the proper method of accessing a counter?.

Counters:

You declare a counter with \newcounter{XXX}, set the counters value with \setcounter{XXX}{1234}. Then you can access it as \theXXX, or \the\value{xxxx}, and both produce the same output:

You can change the desired formatting of the counters output via \renewcommand{\theXXX}{\Roman{XXX}}, after which \theXXX results in the counter's value being displayed in roman numerals:

This technique is often used to change the style of chapter/section, etc... numbers. See for example Roman numerals for sections and subsections.

Dates:

If you are interested in specifically formatting and manipulating dates, you should consider

Code:

\documentclass{article}
\newcounter{XXX}

\begin{document}
\setcounter{XXX}{1234}
\textbackslash{}theXXX yields \theXXX\par
\textbackslash{}the\textbackslash{}value yields \the\value{XXX}

\bigskip
\renewcommand{\theXXX}{\Roman{XXX}}
\textbackslash{}theXXX yields \theXXX\par
\textbackslash{}the\textbackslash{}value yields \the\value{XXX}
\end{document}
-