Fixing undefined variable in datetime field.

Fixes #2593.