Home > Back-end >  mysql
mysql

Time:12-23

Mysql has a date type field data in the table is empty, please how to use the SQL script for the filling

CodePudding user response:

The set dt='2020-12-12'
The set dt=now ()
The set dt=curdate ()

Function description
NOW () returns the current date and time
CURDATE () returns the current date
CURTIME () returns the current time
DATE () to extract the DATE or the DATE of the DATE/time expressions part
EXTRACT () returns the date/time according to the separate parts of the
DATE_ADD (), add the specified time interval to date
DATE_SUB () from the date of minus the specified time interval
DATEDIFF () returns the number of days between two dates
DATE_FORMAT () with different formats display date/time

CodePudding user response:

Now or date_format () function?

CodePudding user response:

reference 1st floor icoolno1 response:
set dt='2020-12-12'
The set dt=now ()
The set dt=curdate ()

Function description
NOW () returns the current date and time
CURDATE () returns the current date
CURTIME () returns the current time
DATE () to extract the DATE or the DATE of the DATE/time expressions part
EXTRACT () returns the date/time according to the separate parts of the
DATE_ADD (), add the specified time interval to date
DATE_SUB () from the date of minus the specified time interval
DATEDIFF () returns the number of days between two dates
DATE_FORMAT () with different formats display date/time


[SQL] update aaa set time='2011-01-01'
Where is null or time=' ';
(Err), 1292 - Incorrect date value: 'for column' time 'at row 1
Such complains

CodePudding user response:

The set time=date (' 2011-01-01 ')

CodePudding user response:

reference time is fleeting mo negative figure 3 floor response:
Quote: refer to 1st floor icoolno1 response:
set dt='2020-12-12'
The set dt=now ()
The set dt=curdate ()

Function description
NOW () returns the current date and time
CURDATE () returns the current date
CURTIME () returns the current time
DATE () to extract the DATE or the DATE of the DATE/time expressions part
EXTRACT () returns the date/time according to the separate parts of the
DATE_ADD (), add the specified time interval to date
DATE_SUB () from the date of minus the specified time interval
DATEDIFF () returns the number of days between two dates
DATE_FORMAT () with different formats display date/time


[SQL] update aaa set time='2011-01-01'
Where is null or time=' ';
(Err), 1292 - Incorrect date value: 'for column' time 'at row 1
Such complains


An error because the where is null or time=' '; Behind of time=", the time='removed