Next Illuminate\Database\QueryException: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '1980-00-00'
Hi! when I try to update date from laravel with Eloquent model it shows error.
But when I do this in phpmyadmin everything works fine.
p.s. I have mysql 5.7 with settings that allow zero date and zero in dates
please halp!
Can you provide the snippet that generates this error?
Are you using a date or timestamp?
I'm using date
Illuminate\Support\Facades\DB::table('persons')->where('id',22)->update(['birthday'=>'1980-00-00']);
Why do you think 1980-00-00 should be accepted by the database?
because I need it and it's working fine, but not in laravel.
if so do you think using 3 separate int columns is good (year, month, day)?
save it like this "1980-00-00 00:00 " and when you want to retrieve it from the database then you can ignore the time
still don't understand why you want to save 1980-00-00
there are 3 scenarious
- person has only year of birth
- person has only month and day of birth
- person has full date
I agree with @Snapey, but if you want to store the information as you describe, then create separate the year, month and day into their own columns.
Please or to participate in this conversation.