I was looking for a deterministic truncate function for datetime and this one did the job:
DATEADD(dd, DATEDIFF(dd, 0, @date), 0)
But this is supposed to be the input to a persisted computed column which will be a part of the primary key, so it has to be non-nullable. So I made this:
ISNULL(DATEADD(dd, DATEDIFF(dd, 0, @date), 0), '01.01.1900')
But now the expression became non-deterministic. Can anyone tell me why, and how I can make it deterministic?
Thanks!