Have you looked at PHP’s date function?
A quick example :
$dates = $wpdb->get_col( /*your sql*/ );
if( $dates )
{
$archive_year = "";
foreach( $dates as $date )
{
$the_date = strtotime( $date );
$year = date( 'Y', $the_date ); //4 digit year, ex 1999
$month = date( 'F', $the_date ); //Full textual month, ex January
if( $year != $archive_year )
{
if( !empty( $archive_year ) ) echo "</ul>";
echo "
<h2>$year</h2>
<ul>
<li>$month</li>
";
}
else
{
echo "<li>$month</li>";
}
}
}
Second example
$dates = $wpdb->get_col( /*your sql*/ );
if( $dates )
{
$archive_year = date( 'Y' ); //Get current year
echo "<h2>$archive_year</h2>";
echo "<ul>";
foreach( $dates as $date )
{
$the_date = strtotime( $date );
$year = date( 'Y', $the_date ); //4 digit year, ex 1999
$month = date( 'F', $the_date ); //Full textual month, ex January
if( $year == $archive_year )
{
echo "<li>$month</li>";
}
}
echo "</ul>";
}