Just for reference, I've decided to download the whole medline and parse the file locally, as I wanted to avoid making hundreds of thousands query updated.
First, I've downloaded the files from ftp://ftp.ncbi.nlm.nih.gov/pubmed/baseline
Since these are xml files, I've extracted the publication date using this XSLT template:
<xsl:stylesheet version="1.0" xmlns:xsl="<a href=" http:="" www.w3.org="" 1999="" XSL="" Transform"="" rel="nofollow">http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:value-of select="MedlineCitation/PMID"/>,<xsl:value-of select="MedlineCitation/Article/Journal/JournalIssue/PubDate/Year"/>,<xsl:value-of select="MedlineCitation/DateCompleted/Year"/>
Then, transformed all the xml files using GNU/parallel and xsltproc. This provided a number of txt files containing three columns (pmid, date of record creation, and date of publication completed), which was merged and formatted with an R script, to get a final 2-columns file with pmid and year.
Interesting fact: I can now officially demonstrate that the PMID does not directly correlate with the publication date, e.g. two papers with consecutive PMID may have been published in completely different years.