Somewhere in there - and I don't see where - there is a string based date being converted to a DATE, DATETIME, or DATETIME2 column, and the data in the string is not a valid date, or is in the wrong format for the server the SQL instance is running on to understand.
Simple solution: stop storing date info as strings and always store it as DATE, DATETIME, or DATETIME2 so SQL doesn't have to try and work out what format the date info is in as it always gives problems.
But that code is weird - you are comparing fixed strings to null and that will succeed, a string cannot be null:
case when '2017-10-25' is null then
So either the code you show us is not what you are actually executing, or that code is ... um ...
different and unusual
I'd start by looking at my columns, and at what code you used to generate that query, if any.