Forum Discussion
luissantos920
Oct 13, 2024Copper Contributor
Supressing date 01-01-1900
I am creating a database view and need to format date field as yyyy-MM-dd while also supressing null dates which are showing up as 01-01-1900. The statement I am using is:
CAST(ISNULL(FORMAT(my_data_dte, 'yyyy-MM-dd'), '') as date) as 'My_Date',
I've tried various ways including IFF and CASE but had no luck 😞
Would appreciate any suggestions.
Thank you
- rodgerkongIron Contributor
IIF is working, like this
DECLARE @a DATE --SET @a = GETDATE() --Run this line get value to test SELECT IIF(@a IS NULL, '', FORMAT(@a, 'yyyy-MM-dd'))
- luissantos920Copper Contributor
Hi there. It worked as suggested.
I also had to remove CAST ( ) as it would turn field into 01-01-1900 again which makes sense.
Thank you!!