Mysql date field
Mysql date field help you to create the data field and their respective data type.
Understanding with Example
The Tutorial illustrate an example to create date field in Mysql. The create table statement is used to create a table 'employee2' with field name and date respectively. The data type used for date is date data type.
Query for creating date field:-
CREATE TABLE employee2( Empid int(10),Empname varchar(60),date date ); |
Output:-
Query for insertion of data:-
The insert into add the records value into the table 'employee2'.The format of date date type is 'YYYY-MM-DD'.
mysql> insert into employee2 values('02','Girish','2008-12-23'); mysql> insert into employee2 values('01','Komal','2008-12-21'); |
Query for viewing data of the table:-
To view a table, we use select Query to display the records from a table 'employee2'.
mysql> select * from employee2; |
Output:-
+-------+---------+------------+ | Empid | Empname | date | +-------+---------+------------+ | 2 | Girish | 2008-12-23 | | 1 | Komal | 2008-12-21 | +-------+---------+------------+ 2 rows in set (0.00 sec) |