[Tex/LaTex] Biblatex urldate set to today

biberbiblatexdatetime

When writing a document I want the urldate (the date of visit) of online bibliographical entries set to the day of compilation. Consider the following MWE:

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\begin{filecontents}{references.bib}
@online{abc,
title = {This is a Title},
author = {Author, Some},
url = {http://www.somesite.com},
date = {2013-10-10},
urldate = {\year-\month-\day} % this does not work. Also urldate = {\today} doesn't.
}
\end{filecontents}

\addbibresource{references.bib}
\begin{document}
\cite{abc}.
\printbibliography
\end{document}

Unfortunately this does not work. The hypthens are in the text because biblatex expect dates to be in the form of yyyy-mm-dd. Any ideas on how to resolve this issue?

Best Answer

You can achieve this with the following:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
       \pertype{online}
       \step[fieldset=urldate,fieldvalue={\the\year-\the\month-\the\day}]
    } 
 }
}

This definition overwrites every urldate field of the type online and used the current date.

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{references.bib}
@online{abc,
title = {This is a Title},
author = {Author, Some},
url = {http://www.somesite.com},
date = {2013-10-10},
urldate = {xxxx} % this does not work. Also urldate = {\today} doesn't.
}
\end{filecontents}


\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
       \pertype{online}
       \step[fieldset=urldate,fieldvalue={\the\year-\the\month-\the\day}]
    } 
 }
}
\addbibresource{references.bib}
\begin{document}
\cite{abc}.


\printbibliography
\end{document}

enter image description here