SELECT 12 * extract(year from date1) + extract(month from date1) - 12 * extract(year from date2) - extract (month from date2) as month_spread FROM foo