# datetime: date without year

This question is similar to Format date without year, but I can't deduce the answers. I would like to delete the year in a date,

\documentclass{article}
\usepackage[spanish,mexico]{babel}
\usepackage{datetime}
\begin{document}
I have: \today
I want: 15 de diciembre
I have: \longdate\today
I want: lunes 15 de diciembre
\end{document}


as I use babel-spanish, is enough in this language, but in other language can be useful for other people.

datetime provides the \newdateformat command for just such cases:

\documentclass{article}
\usepackage[spanish,mexico]{babel}
\usepackage{datetime}
\newdateformat{myshort}{%
\THEDAY\ de \monthname[\THEMONTH]%
}
\newdateformat{mylong}{%
\dayofweekname{\THEDAY}{\THEMONTH}{\THEYEAR}
\THEDAY\ de \monthname[\THEMONTH]%
}
\begin{document}
I have: \today

I now have: \myshort\today

I want: 15 de diciembre

I have: \longdate\today

I now have: \mylong\today

I want: lunes 15 de diciembre
\end{document}


• Thanks! This solution is more add-hoc to the package datetime. You just need to add a symbol % after [\THE MONTH], in both commands, because it adds a small space. If you write a period after the command, you can see it clearly. – Gitano Dec 16 '14 at 22:24
• @Gitano Fixed :-) – Brent.Longborough Dec 17 '14 at 4:08

I don't speak any kind of Spanish, but this purely revolves around an update to \formatdate. Below I've supplied \noyeardate which removes the year from being output. Additionally, it prepends de to the month name:

\documentclass{article}
\usepackage[spanish,mexico]{babel}
\usepackage{datetime}

\makeatletter
\let\oldmonthname\monthname
\DeclareRobustCommand*{\longdate}{%
\renewcommand*{\formatdate}[3]{%
\ifshowdow\dayofweekname{##1}{##2}{##3} \fi
\@day=##1\relax\@month=##2\relax\@year=##3\relax
\ordinaldate{\the\@day}\ \monthname[\@month]}%, \the\@year}%
\renewcommand{\monthname}{de \oldmonthname}%
}
\DeclareRobustCommand*{\noyeardate}{%
\renewcommand*{\formatdate}[3]{%
\@day=##1\relax\@month=##2\relax\@year=##2\relax
\number\@day~de \monthname[\@month]}%
}
\makeatother

\begin{document}

\noyeardate
I have: \today

I want: 15 de diciembre

\bigskip

I have: \longdate\today

I want: lunes 15 de diciembre

\end{document}