
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we insert current year automatically in a YEAR type column of MySQL table?
It can be done by using either CURDATE() or NOW() in MySQL query as follows −
mysql> Insert into year1(Year_Copyright) values (CURDATE()); Query OK, 1 row affected, 1 warning (0.06 sec) mysql> Select * from year1; +----------------+ | Year_Copyright | +----------------+ | 2017 | | 2017 | +----------------+ 2 rows in set (0.00 sec) mysql> Insert into year1(Year_Copyright) values (NOW()); Query OK, 1 row affected, 1 warning (0.06 sec) mysql> Select * from year1; +----------------+ | Year_Copyright | +----------------+ | 2017 | | 2017 | | 2017 | +----------------+ 1 rows in set (0.00 sec)
- Related Articles
- How can we insert current date automatically in a column of MySQL table?
- Can we use “year” as a column came in a MySQL Table?
- How MySQL use YEAR data type to store year value in a table?
- How can we insert current date and time automatically on inserting values in other columns in MySQL?
- Create a dynamic table name from current year in MySQL like 2019
- How can we change the data type of the column in MySQL table?
- Select last day of current year in MySQL?
- How can fetch records from specific month and year in a MySQL table?
- Get current year in MySQL WHERE clause?
- How can we insert data into a MySQL table?
- How can we use INSERT() function to insert a new string into the value of a column of MySQL table?
- How can we extract the Year and Month from a date in MySQL?
- Add a single year to all the date records in a MySQL table column
- How can we insert a new row into a MySQL table?
- How can we calculate the number of seconds in a leap year?

Advertisements