This is caused by the to_char()
function padding the month name with spaces. This can either be fixed by applying a trim()
on the result or using the FM
modifier in the format mask:
SELECT ea_month,
CASE
WHEN ea_month = to_char(current_date, 'FMMonth') THEN 1
ELSE 0
END,
ea_year,
zone_id
FROM staging_ea.stg_circle_zone_billedamount_rollup;
See the manual for details: http://www.postgresql.org/docs/current/static/functions-formatting.html#FUNCTIONS-FORMATTING-DATETIMEMOD-TABLE