# Trouble using \formatdate inside \caption

I am having trouble formatting a date inside a caption using the datetime package. I'm told "Incomplete \iffalse; all text was ignored after line 6.

\documentclass{article}
\usepackage{datetime}
\begin{document}

\begin{figure}[h]
\caption{Something that happened on \formatdate{30}{9}{2010}}
\end{figure}

\end{document}


If \formatdate is removed from \caption, the document compiles as expected. Also, I have tested \formatdate and it works when placed elsewhere. It seems to not like captions though...

So, any ideas how to format a date inside a caption?

-

You can use protect

documentclass{article}
\usepackage{datetime}
\begin{document}

\begin{figure}[h]
\caption{Something that happened on \protect\formatdate{30}{9}{2010}}
\end{figure}

\end{document}

-
Awesome! Thanks. –  user2470 Dec 13 '10 at 7:48