Do something if first entry of a year I'm outputting a timeline for company history and i'd like to add a graphic for the Year before the first entry of each year. My current code is as follows:

{% set companyHistory = craft.entries.section('about').slug('company-history').first() %}

{% for moment in companyHistory.children.type('history') %}
    &lt;li&gt;{{ moment.title }}&lt;/li&gt;
{% endfor %}


My date field is simply called 'date'. How might I go about this with the fewest possible DB queries?
I got it using the 'group' filter at : http://buildwithcraft.com/docs/templating/filters#group

Thanks to Steve Abraham for pointing me in the right direction. My code that seems to work is:

{% set companyHistory = craft.entries.section('about').slug('company-history').first() %}
{% set allEntriesByYear = companyHistory.children.type('history') | group('date.year') %}

{% for year, entriesInYear in allEntriesByYear %}
    &lt;h2&gt;{{ year }}&lt;/h2&gt;
    {% for moment in entriesInYear %}
        &lt;li&gt;{{ moment.title }}&lt;/li&gt;
    {% endfor %}
{% endfor %}


Let me know if there is an even better solution.