0

I'm trying to change the dateformat in my bibliography, which is currently d.m.yyyy (eg 6.7.2022) and should be dd.mm.yyyy (06.07.2022).

Here is what I'm doing:

\DeclareFieldFormat{urldate}{%
\thefield{urlday}\adddot%
\thefield{urlmonth}\adddot%
\thefield{urlyear}\isdot}

I tried calling biber with dateabbrev=false and urldate=long, which doesn't work. Is there a way to display urlday and urlmonth with leading 0, if needed?

Edit: Here is a MWEB (I hope it's minimal enough, but I wasn't sure what I could ommit without issues)

\documentclass[12pt, numbers=noenddot]{scrreprt}
\usepackage[a4paper]{geometry}
\usepackage{pdfpages}
\usepackage[utf8]{inputenc}
\usepackage{helvet}
\usepackage[ngerman, british]{babel}
\usepackage{csquotes}
\usepackage[parfill]{parskip} % paragraphs not indentated
\usepackage[backend=biber, dateabbrev=false, citestyle=numeric, sorting=none, urldate=long, bibstyle=authoryear]{biblatex}
\usepackage{color}
\usepackage{xpatch} % correct dots in chapters and sections
\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}
\xpretocmd\chapterformat
  {\def\autodot{.}}% replace \autodot by a fixed dot for chapter headings
  {}{\cfPatchFailed}%
\RedeclareSectionCommand[
  beforeskip=-1sp,
  tocentrynumberformat=\def\autodot{.}% replace \autodot by a fixed dot for chapter entries
]{chapter}

\MakeOuterQuote{"} % german quotes
\selectlanguage{ngerman}
\renewcommand{\familydefault}{\sfdefault} % Arial
\linespread{1.25} % equals 1.5 spacing in word
\addbibresource{\jobname.bib}

\begin{filecontents}{\jobname.bib}
@book{key,
  author = {Author, A.},
  year = {2001},
  title = {Title},
  urldate = {2022-07-06},
  publisher = {Publisher},
}
\end{filecontents}
\AtEveryBibitem{[\printfield{labelnumber}]\addspace} % Numbers in the bib
\setlength{\bibhang}{0pt} % no indentation in bibliography

\DeclareFieldFormat{urldate}{%
  [\thefield{urlday}\adddot%
  \thefield{urlmonth}\adddot%
  \thefield{urlyear}\isdot]
}
\begin{document}

\cite{key}

\printbibliography

\end{document}

I guess something with my language is wonky - the reason I am loading ngerman and british is so that I get et al. instead of u.a. in my bibliography

5
  • 1
    The code shown is not the best way of getting dd.mm.yyyy date format. What is the best way depends on your language settings. biblatex will adapt its output to the document language. Please show us a small example document that show which bibliography style you use and which language settings your document has (babel/polyglossia).
    – moewe
    Commented Dec 8, 2022 at 5:57
  • Welcome to TeX.SX! For more information about how to make a small example, that can be used to reproduce the issue, see, e.g., How to write a MWEB (Minimal working example with Bibliography)?
    – cabohah
    Commented Dec 8, 2022 at 7:33
  • Thanks for getting back to me @moewe - I have added a more complete example, I hope that's more helpful!
    – Brian
    Commented Dec 8, 2022 at 12:10
  • So what's the idea with the language settings? Your document is in German and you only want to get "et al." instead of "u.a.". That's why you load british?
    – moewe
    Commented Dec 8, 2022 at 22:30
  • Yes, that was the idea originally. However I have now removed british and changed the "u.a." by using \DefineBibliographyStrings. However there were some other things wrong with the code I have posted here, and I was missing some stuff to get the urldate to be formated exactly as DD.MM.YYYY (in my specific case I need [] around the date too, but that doesn't really change anything). I'll go ahead and add what I did as an answer.
    – Brian
    Commented Dec 9, 2022 at 0:37

1 Answer 1

1

First mistake was using british in addition to ngerman because I wanted my bibliography to say "et. al" instead of "u.a.", so I removed the british option from babel and instead used

\DefineBibliographyStrings{ngerman}{
   andothers = {{et\,al\adddot}},
}

for that.

Then I removed what I initially hoped to be the solution

\DeclareFieldFormat{urldate}{%
\thefield{urlday}\adddot%
\thefield{urlmonth}\adddot%
\thefield{urlyear}\isdot}

and finally I removed dateabbrev=false and urldate=long from the biblatex options.

Now urldate is displayed as "besucht am DD.MM.YYYY".

To remove the "besucht am" I did

\DeclareFieldFormat{urldate}{[#1]}

which now shows urldate as [DD.MM.YYYY].

You must log in to answer this question.

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