Comment
Shane J
Tera Guru

I'd suggest sending your problematic values to the Log so you know exactly what is being passed.  You may end up changing your Date input to a String instead of Date when all is said and done.  I'm not entirely sure what your end goal is though, since I don't see a .update() anywhere in your script to actually change the variable.

You may need to look at my previous post as well, since I think you're using the original post which myself and others have had issues with.