How to avoid write conflicts on datetime fields


If you choose a date/time format that does not include seconds for a grid text field, but store seconds in the DATETIME field in your database, you can encounter write conflicts if the stored values have non-zero seconds. For example, you might choose this as your date/time format:

time("{grid.clientSideDateFormat} 0h:0m",<value>)

This would normally not be a problem, unless the value in your database that you are trying to update were something like this:

2012-01-19 12:54:23
It is important to note the 23 seconds here

So, the value that you send back to the server as the original value for the field will therefore be:

2012-01-19 12:54

This of course is not the same as 2012-01-19 12:54:23, and the grid will throw a write conflict. If you want to or are storing seconds in your date/time fields, you need to choose a date/time format that includes seconds, e.g.:

time("{grid.clientSideDateFormat} 0h:0m:0s",<value>)
The 's' in the time format! If you don't want to display seconds in updateable grid date/time fields, then you need to clean your data on the server to remove the seconds.