# Custom export filter month field

**URL:** <https://discourse.jabref.org/t/custom-export-filter-month-field/1214>\
**Category:** Help\
**Created:** [June 21, 2018, 5:58pm UTC](https://discourse.jabref.org/t/custom-export-filter-month-field/1214 "2018-06-21T17:58:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![webanck](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/webanck/32/435_2.png) [@webanck](https://discourse.jabref.org/u/webanck)\
**Post date:** [June 21, 2018, 5:58pm UTC](https://discourse.jabref.org/t/custom-export-filter-month-field/1214/1 "2018-06-21T17:58:31Z")

</div>

Hello, I am writing a custom export filter in order to create a simplified bibtex bibliography from selected entries.  
If I find the expansion of the Bibtex custom strings usefull, I have a problem against the expansion of the month field.  
Indeed, to allow using smoothly the Bibtex file for non English documents, I would like to be able to recover the month number associated to the field instead of the full name in English.

To sum up, with a database file such as this:

> @String{acmtog = {ACM} Transaction on Graphics}  
> @Article{key,  
> […]  
> journal = acmtog,  
> date = {2018-06}  
> }

And a custom export filter like this:

> @\bibtextype{\bibtexkey,\begin{journal},  
> journal = {\journal}\end{journal}\begin{month},  
> month = {\month}\end{month}  
> }

I get something like:

> @Article{key,  
> //[…]  
> journal = {SIGGRAPH Computer Graphics}, //nice!  
> month = {January}, //why not the month number? how to get it?  
> }

Any idea to get the number of the month instead of its name in English?

---

<div class="post-metadata">

**Author:** ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)\
**Post date:** [June 21, 2018, 8:55pm UTC](https://discourse.jabref.org/t/custom-export-filter-month-field/1214/2 "2018-06-21T20:55:28Z")

</div>

Hi,

I think this could be possible by using the date formatter. Evenif you only have month setup, as date is an alias field for month + year.

It should be sufficient either with M for single month or MM for month with leading zero

> DateFormatter : formats a date. With no argument, the date is given in ISO-format (yyyy-MM-dd), which is also the expected format of the input. The argument may contain yyyy, MM, and dd in any combination. For example \format[DateFormatter(MM/yyyy)]{\date} will output 07/2016 if the date field contains 2016-07-15.

> **[JabRef Bibliography Management](https://help.jabref.org/en/CustomExports)**

---

<div class="post-metadata">

**Author:** ![webanck](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/webanck/32/435_2.png) [@webanck](https://discourse.jabref.org/u/webanck)\
**Post date:** [June 22, 2018, 6:01am UTC](https://discourse.jabref.org/t/custom-export-filter-month-field/1214/3 "2018-06-22T06:01:33Z")

</div>

Well, first, thanks for your answer!  
I just tried to use the DateFormatter, which seemed exactly what I needed, as you pointed out.

So I wrote:

> @\bibtextype{\bibtexkey,\begin{journal},  
> journal = {\journal}\end{journal}\begin{month},  
> month = \format[DateFormatter(MM)]{\date}\end{month}  
> }

But I get an error:

> Text ‘2013-10’ could not be parsed at index 7

So I tried:

> @\bibtextype{\bibtexkey,\begin{journal},  
> journal = {\journal}\end{journal}\begin{month},  
> month = \format[DateFormatter(MM)]{2013-10}\end{month}  
> }

And get the same error.  
But if I write for example:

> @\bibtextype{\bibtexkey,\begin{journal},  
> journal = {\journal}\end{journal}\begin{month},  
> month = \format[DateFormatter(MM)]{2013-10-01}\end{month}  
> }

It is working.

So, is it a bug or what?

---

<div class="post-metadata">

**Author:** ![tobiasdiez](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/tobiasdiez/32/340_2.png) [@tobiasdiez](https://discourse.jabref.org/u/tobiasdiez)\
**Post date:** [June 26, 2018, 3:53pm UTC](https://discourse.jabref.org/t/custom-export-filter-month-field/1214/4 "2018-06-26T15:53:29Z")

</div>

Yes, that’s a limitation of the current implementation. It always expects a full ISO date [https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/logic/layout/format/DateFormatter.java#L15](https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/logic/layout/format/DateFormatter.java#L15). Could you please open a bug report at [https://github.com/JabRef/jabref/issues](https://github.com/JabRef/jabref/issues) thanks!
