How to insert the date value in MySQL

Here we will see how we can insert date value in MySQL table having date column.

Date value can be inserted in MySQL column like a string value and format of date will be YYYY-MM-DD.

  • YYYY is year
  • MM is month
  • DD is date

We have Dept table having data

mysql> select * from dept;
+----+---------+------------+-------------------+
| id | name    | Dept_owner | Dept_Created_date |
+----+---------+------------+-------------------+
|  1 | IT      | NULL       | 2021-01-01        |
|  2 | Faculty | NULL       | NULL              |
+----+---------+------------+-------------------+
2 rows in set (0.00 sec)

We will insert the date value in Dept_Created_date column using insert query.

insert into dept value(3,'HR','Steve','2020-03-04');

mysql> select * from dept;
+—-+———+————+——————-+
| id | name | Dept_owner | Dept_Created_date |
+—-+———+————+——————-+
| 1 | IT | NULL | 2021-01-01 |
| 2 | Faculty | NULL | NULL |
| 3 | HR | Steve | 2020-03-04 |
+—-+———+————+——————-+
3 rows in set (0.00 sec)

Scroll to Top