Using php and mysql (and Drupal), I want to generate an index based on the number of items in the database by year - 20090001, 20090002, 20090003, etc.
Is there a way to do this without testing if the year has changed for each and every item - a cron job perhaps?