# Biblatex urldate set to today

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}

\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?

• This is a bad idea. Surely the urldate should be the date the page was visited. If the page has changed in the meantime, it might be that the text you quote on the page (which was there when you visited the page last week) is no longer there. So surely you want the urldate to pick out a date when it really was the case that the quote was at that location... Setting the urldate to today's date makes the field completely useless. – Seamus Dec 11 '13 at 13:53
• I agree with @Seamus, but nonetheless a conceptually interesting question (with a proper MWE), so +1. – doncherry Dec 11 '13 at 14:01

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}]
}
}
}
\begin{document}
\cite{abc}.

\printbibliography
\end{document}


• I would like to do this for some articles (mine) but not for all. Is this possible as well? – Stefan Müller Feb 22 '18 at 17:34

Not exacty what you asked for, but perhaps a compromise of sorts, taking into consideration @Seamus’ comment. I store a specific date (if you want, today) in a string and refer to that string in the single entries.

\documentclass{article}
\usepackage[backend=biber]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@string{today = {2013-12-11}}

@online{abc,
title = {This is a Title},
author = {Author, Some},
url = {http://www.somesite.com},
date = {2013-10-10},
urldate = today,
}
\end{filecontents}