I still struggle with the expansion of Latex. I try to calculate the a real number from a date format and put this into a macro \value. I need to expand the command with \edef because I plan to use the value as a parameter in pgfplots.
\documentclass[10pt]{article} \usepackage{tikz} \usepackage{pgfcalendar} \newcount\mycount \begin{document} \newcommand{\dateconvert}[1]{% \pgfcalendardatetojulian{#1}{\mycount} \pgfcalendarjuliantodate{\mycount}{\myyear}{\mymonth}{\myday} \pgfmathparse{(\myday-1)/365+(\mymonth-1)/12+\myyear}\let\mydate\pgfmathresult \mydate } \dateconvert{2010-07-01} %works \edef\value\dateconvert{2010-07-01} \value %does not work: Use of \value doesn't match its definition \end{document} Calling \dateconvert directly works. However, when I try to copy the result into \value, it fails.
\dateconvertperforms various assignments it’s not fully expandable. So you can’t use it in an\edefcontext. By the way, if\dateconvertwere fully expandable you would have to write\edef\value{\dateconvert{2010-07-01}}.\valueis a LaTeX kernel macro, so it's a bad idea to redefine it: you should pick a different name!