[Tex/LaTex] Don’t print year for online entries in biblatex 2.7

biblatex

With the new version of biblatex (probably implemented in version 2.6, cf. https://tex.stackexchange.com/a/126261/9077), ONLINE entries are now printed with full dates, with that information taken from the URLDATE field. I would like to suppress that (so that it appears like it did in version 2.5).

I can add \clearfield{labelmonth} and \clearfield{labelday} to my preamble to suppress the month and the day, but I can't add \clearfield{labelyear}, since that will remove the year from all other entries in the bibliography as well.

What can I add to my preamble to suppress printing the year in ONLINE entries only?

\documentclass{article}
\usepackage{csquotes,filecontents}
\usepackage[style=authoryear]{biblatex}
\AtEveryBibitem{\clearfield{labelmonth}}
\AtEveryBibitem{\clearfield{labelday}}
%\AtEveryBibitem{\clearfield{labelyear}}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1972,
    AUTHOR = "John Lennon",
    TITLE = "Peace on earth",
    YEAR = "1972"}
@ONLINE{googletranslate,
    TITLE = "Google Translate",
    SHORTHAND = "Google Translate",
    URL = "http://translate.google.com/",
    URLDATE = "2013-08-01"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
I managed to read \cite{lennon1972} with the help of \cite{googletranslate}.
\printbibliography
\end{document}

enter image description here

Best Answer

You can clear the field conditionally for selected type(s):

\AtEveryBibitem{%
  \ifentrytype{online}{%
    \clearfield{labelyear}%
  }{%
  }%
}

A complete example

\documentclass{article}
\usepackage{csquotes,filecontents}
\usepackage[style=authoryear]{biblatex}
\AtEveryBibitem{\clearfield{labelmonth}}
\AtEveryBibitem{\clearfield{labelday}}

\AtEveryBibitem{%
  \ifentrytype{online}{%
    \clearfield{labelyear}%
  }{%
  }%
}

\begin{filecontents}{\jobname.bib}
@BOOK{lennon1972,
    AUTHOR = "John Lennon",
    TITLE = "Peace on earth",
    YEAR = "1972"}
@ONLINE{googletranslate,
    TITLE = "Google Translate",
    SHORTHAND = "Google Translate",
    URL = "http://translate.google.com/",
    URLDATE = "2013-08-01"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
I managed to read \cite{lennon1972} with the help of \cite{googletranslate}.
\printbibliography

\end{document}

enter image description here

Related Question