8

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?

2
  • 6
    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
    Commented Dec 11, 2013 at 13:53
  • 2
    I agree with @Seamus, but nonetheless a conceptually interesting question (with a proper MWE), so +1.
    – doncherry
    Commented Dec 11, 2013 at 14:01

2 Answers 2

8

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

1
  • I would like to do this for some articles (mine) but not for all. Is this possible as well? Commented Feb 22, 2018 at 17:34
3

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}

\addbibresource{\jobname.bib}

\begin{document}
\cite{abc}.
\printbibliography
\end{document}

output

1
  • 2
    This is the way I used to deal with the situation, but I thought there could be a better solution hence the question. Commented Dec 11, 2013 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .