Conversion failed when converting the varchar value 'Jan 1 1900 12:00AM' to data type int
You have:

max(cast(Date_Last_Data_Changed as varchar(255))) &gt;1900


So you're converting to a string, and then comparing that string to an integer. I think you meant:

max(convert(char(8), Date_Last_Data_Changed, 112)) &gt; '19000101'


Or just

max(Date_Last_Data_Changed) &gt; '19000101'


Note that converting to varchar(255) without a style (e.g. 112) yields a string that will not sort the way you expect, since it is sorting as a string, and when you put month name first, it doesn't work. Dec &lt; Jan, for example.