Using SQL in coalesce with Date

1

I have the following question. In SQL your doing so works.

...and coalesce(tb_cadastro.cod_produto,'') = coalesce(:COD_PRODUTO, coalesce(tb_cadastro.cod_produto,'')) and ...

Where COD_PRODUTO is an integer, what would I do if the field is of type DATE ? I've tried it that way, but I can not filter for a date.

...and coalesce(cast(tb_cadastro.dt_pallet AS varchar(10)),'') = coalesce(:DT_PALLET, coalesce(cast(tb_cadastro.dt_pallet AS varchar(10)),''))
    
asked by anonymous 18.10.2018 / 13:29

1 answer

0

Resolved as follows:

...and cast(coalesce(tb_cadastro.dt_pallet,'')as date) = coalesce(:DT_PALLET, cast(coalesce(tb_cadastro.dt_pallet,'') as date))
    
18.10.2018 / 14:43