You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Occasionally database updates and inserts fail with Conversion failed when converting date and/or time from character string because the date format generated from Carbon::now() is incorrect.
I say occasionally, because it looks like the chances of this occuring are slim, but it is happening. For example, this is the query generated for an update where the dates in the model are both set to Carbon::now() update [Table] set [FirstDate] = '2018-08-31 10:32:23.999', [SecondDate] = '2018-08-31 10:32:23.1000' where [Id] = 13381
Note the format of the SecondDate... it's not valid, surely it should be 2018-08-31 10:32:24.000
Steps To Reproduce:
Obviously this is tricky, as it seems to rely on performing and insert or update at exactly 0.999 of a second.
I've done a workaround by fixing all the formats used during updates and inserts using Carbon::now()->format('Y-m-d H:i:s') or Carbon::now()->format('Y-m-d'), but this is a bit of a pain.
I wish I didn't have to use SQL server, but this is a new front end to a legacy system, so I've no choice.
The text was updated successfully, but these errors were encountered:
Description:
Occasionally database updates and inserts fail with
Conversion failed when converting date and/or time from character string
because the date format generated from Carbon::now() is incorrect.I say occasionally, because it looks like the chances of this occuring are slim, but it is happening. For example, this is the query generated for an update where the dates in the model are both set to Carbon::now()
update [Table] set [FirstDate] = '2018-08-31 10:32:23.999', [SecondDate] = '2018-08-31 10:32:23.1000' where [Id] = 13381
Note the format of the SecondDate... it's not valid, surely it should be
2018-08-31 10:32:24.000
Steps To Reproduce:
Obviously this is tricky, as it seems to rely on performing and insert or update at exactly 0.999 of a second.
I've done a workaround by fixing all the formats used during updates and inserts using
Carbon::now()->format('Y-m-d H:i:s')
orCarbon::now()->format('Y-m-d')
, but this is a bit of a pain.I wish I didn't have to use SQL server, but this is a new front end to a legacy system, so I've no choice.
The text was updated successfully, but these errors were encountered: