SSRS report expression FormatDateTime changes Nulls to '1/1/0001'
-
18-01-2021 - |
Pregunta
I have a report where I need to remove the time from a datetime column. I've found this expression to work but it changes all the null values to '1/1/0001'
=FormatDateTime(Fields!Temperature_Control_Inspection_Date.Value,DateFormat.ShortDate)
I have tried the below expression to look for nulls but it doesn't appear to work.
=IIF(Fields!Temperature_Control_Inspection_Date is nothing, nothing, FormatDateTime(Fields!Temperature_Control_Inspection_Date.Value,DateFormat.ShortDate))
How can I show just the Date from a DateTime column without also having all the nulls replaced by '1/1/0001'?
Solución
Below will work :
=IIf(IsNothing(Fields!Temperature_Control_Inspection_Date.Value), "", FormatDateTime(Fields!Temperature_Control_Inspection_Date.Value, DateFormat.ShortDate))
Above will have null dates as blank. Also, it will remove the time and just get you the date portion.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a dba.stackexchange