Fix `datetime.to_s(:db)`

`to_s` on `nil` requires zero parameters. Use `try` to bypass calling
`to_s` on `nil`
Merge pull request #429 from doitian/rails4-fix-datatime-to-s

[Rails4] Fix `datetime.to_s(:db)`