I have a date field that is written to the field in JSON format, along with other values
{"data_limite":"14\/07\/2016","data_programada":null,"admin_agendamento":"4813"}
This "deadline" field, I need on another screen to put in a CASE-WHEN to check if that date is 24, 48 or 72 hours from today.
This is my question: How to perform a comparison in a CASE-WHEN with a data recorded with other values?
EDIT : My postgres is 8.3, so without JSON support, it is written to a TEXT field
EDIT 2 : SQL Excerpt I have to execute:
...
CASE
WHEN tbl_cliente_admin.nome IS NOT NULL AND tbl_hd_chamado_extra.hd_chamado NOT NULL AND finalizada IS NULL AND array_campos_adicionais NOT NULL AND (AQUI TENHO QUE COMPARAR)::date - CURRENT_DATE >= 3
THEN 3
WHEN tbl_cliente_admin.nome IS NOT NULL AND tbl_hd_chamado_extra.hd_chamado NOT NULL AND finalizada IS NULL AND array_campos_adicionais NOT NULL AND (AQUI TENHO QUE COMPARAR)::date - CURRENT_DATE > 1
THEN 2
WHEN tbl_cliente_admin.nome IS NOT NULL AND tbl_hd_chamado_extra.hd_chamado NOT NULL AND finalizada IS NULL AND array_campos_adicionais NOT NULL AND (AQUI TENHO QUE COMPARAR)::date - CURRENT_DATE <= 1
THEN 1
ELSE 4
END AS termino_atendimento
...