12

I have the problem that I use the citation manager Citavi and it can only export in the format urldate = {dd.mm.yyyy}. However Bibtex needs the format urldate = {yyyy-mm-dd}. It is not really realistic in my case to change all the dates of my bibliography manually, as I have many entries and after each export I would need to redo it.

For example my bibtex entry looks like this:

@Misc{FAO.2011,
  Title                    = {{FAOSTAT: Food balance sheet}},
  Author                   = {FAO},
  Year                     = {2011},
  Address                  = {Rome},
  Url                      = {http://faostat3.fao.org/download/FB/FBS/E},
  Urldate                  = {15.1.2014}
}

Then I receive following warning, when I compile it with BibTex

Package biblatex Warning: Biber reported the following issues
(biblatex) with 'FAO.2011':
(biblatex) - Datamodel: Entry 'FAO.2011' (literature.bib): Inval
id format '15.1.2014' of date field 'urldate' - ignoring.

Is there any way to change the format of Bibtex that it reads the urldate in format urldate = {dd.mm.yyyy} or can I convert it somehow to urldate = {yyyy-mm-dd}?

I have searched in the internet and haven't found any solution for this problem. It seems to be a specific problem of Citavi. To bad that Citavi is not customizable.

My question is similar to this: Ignore a bibliography field [e.g. "urldate"] for eliminating of biblatex/biber warnings. However, no solution was provided in this topic for my problem, because in this case urldate was not needed and thus just ignored. But I need to give urldate.

1
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Commented Feb 19, 2015 at 18:07

5 Answers 5

9

Thanks to Giacomo's feedback, I found another solution for this specific problem:

The problem is somehow more related to Citavi and Citavi is not as clear or transparent as LaTeX. For future reference of other people who might encounter a similar problem: Although Citavi asks to provide the date in the format urldate={dd.mm.yyyy} you can type it in as urldate = {yyyy-mm-dd}. The export does not make any problem. Strangly, by just changing one entry, all the other entries are exported accordingly. My fault not trying it out earlier. I should have tried it out earlier.

2
  • You could also use sed (stream editor), to edit the files. Commented Nov 7, 2015 at 22:07
  • Is there a setting option in citavi to change the date format in general?
    – Rob Bauer
    Commented May 16, 2022 at 17:09
8

If you are using biblatex package you can use

\DeclareSourcemap{
    \maps{
        \map[overwrite]{
            \step[fieldsource=urldate,
            match=\regexp{([0-9]{2})\.([0-9]{2})\.([0-9]{4})},
            replace={$3-$2-$1},
            final]
        }
    }
}

in your preamble to reformat urldate field of input *.bib files.

2
  • an example of the output for this would be pretty helpful
    – baxx
    Commented Sep 26, 2018 at 0:55
  • The code seems not working Commented May 4, 2022 at 9:26
1

for forcing the formatting in BibTeX, I use the double braces, e.g.:

Urldate  = {{15/01/2014}}
3
  • This seems not idiomatic and has to be done for every single bibliography entry. Commented Feb 15, 2023 at 18:29
  • With biblatex (which the question is about) this won't work. Input in date fields must be given in ISO 8601 format. Input that cannot be parsed as ISO 8601 is ignored. If I try the input I get Entry '<entrykey>' (<file name>): Invalid format '{15/01/2014}' of date field 'urldate' - ignoring and no urldate output whatsoever.
    – moewe
    Commented Mar 3, 2023 at 6:54
  • This migtht work for BibTeX styles that support a urldate field. But I don't think there are a lot of those (if any).
    – moewe
    Commented Mar 3, 2023 at 6:55
1

For the sake of completeness, and because I just stumbled upon this: Citavi 6 includes a setting for this, found under Options - Formatting.

It will then use the chosen format for new entries, and when you insert the current date through the context menu. Existing dates are NOT updated.

screenshot of options dialog

0

I wrote a little python script that changes the format of urldate: place your .bib file in the same directory than this script and name it "quellen.bib" and run the script. A new formated file named "changedFile.bib" will appear

import re

file = open("quellen.bib","r");
fileChanged = open("changedFile.bib","w");
pattern = re.compile("([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})");

for line in file:
    if "urldate =" in line and pattern.search(line):
        #save end of line to add it later to the modified date
        endline = line[line.index('}')+1:len(line)];
        date = line[line.index('{')+1:line.index('}')];
        month = int(date[0:date.index('/')]);
        date = date[date.index('/')+1:len(date)];
        day = int(date[0:date.index('/')]);
        date = date[date.index('/')+1:len(date)];
        year = int(date);
        if month > 12:
            # check if month and day are reversed
            temp = day;
            day = month;
            month = temp;
        # check if every value is ledgit
        if(month > 0 and month < 13 and day >0 and day < 32 and year > 1000):
            if(month<10):
                #add 0 if month or day is less then 10
                month = "0"+str(month);
            if(day<10):
                day = "0"+str(day);    
            fileChanged.write(" urldate = {"+ str(year)+"-"+str(month)+"-"+str(day)+"}"+endline);
        else:
            print("something is wrong with this line: ");
            print("day: ",day,"montH: ",month, "year: ",year);
            print(line);
    else:
        fileChanged.write(line);
file.close;
fileChanged.close;

    

You must log in to answer this question.

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