def extract_accessions_and_dates(genbank_query, taxonomy_filters):
    """Retrieve the GenBank accessions and retrieval dates of existing sequences from the db query.

    :param genbank_query: sql collection
    :param taxonomy_filters: set of genera, species and strains to restrict retrieval of sequences

    Return a dict {GenBank_accession: retrieval_date}
    """
    accessions = {}

    if taxonomy_filters is None:
        for item in genbank_query:
            if item[0].genbank_accession == "NA":  # no GenBank accession stored in CAZy
                continue
            accessions[item[0].genbank_accession] = item[0].seq_update_date

    else:
        for item in genbank_query:
            if item[0].genbank_accession == "NA":  # no GenBank accession stored in CAZy
                continue
            source_organism = item[-1].genus + item[-1].species
            if any(filter in source_organism for filter in taxonomy_filters):
                accessions[item[0].genbank_accession] = item[0].seq_update_date

    return accessions