SQl Date

This page discusses - SQl Date

SQl Date

SQL Date

     

The SQL Date is used when you are working with dates. This include the format of data ,the insert value matches the format of the data column  in the database. The query contain only the date portion, which you want to retrieve the data as per your given query. 

Understand with Example

The Tutorial illustrate a Example from SQL Date. In this Tutorial, we create  a  Table 'Stu_Table' with its field attribute and data type using create table statement in database. The insert into statement is used to insert the records or rows into table of the database.

  create table : The create table keyword in SQL Statement is used to create a table in database.

  Insert into : The insert into is used to add the records or rows value into the table of database.

The field attribute used in 'Stu_Table' are Stu_Id,Stu_Name,Stu_Class and Stu_Dob and their data types are integer, varchar and Date respectively. The create statement show you a table Stu_Table with the specified fields. The data type for storing a date or date value in database is given as:

  Date : The format used to store the Date is YYYY-MM-DD 

Once your table is created, The insert into query will run to add the records or rows to your create Stu_Table Table in your database.The select is used to retrieve the records or rows from a table Stu_Table. 

Create Table Stu_Table

create table Stu_Table(Stu_Id integer(2), Stu_Name varchar(15),
Stu_Class  varchar(10), Stu_Dob Date)

Insert data into Stu_Table

insert into Stu_Table values(1,'Komal',10,'1999,11,1');
insert into Stu_Table values(2,'Ajay',10,'1999,10,1');
insert into Stu_Table values(3,'Rakesh',10,'1999,11,1');
insert into Stu_Table values(4,'Bhanu',10,'1999,11,1');
insert into Stu_Table values(5,'Santosh',10,'1999,11,1');

Stu_Table

Stu_Id Stu_Name Stu_Class Stu_Dob
1 Komal 10 1999-11-1
2 Ajay 10 1999-10-1
3 Rakesh 11 1999-11-1
4 Bhanu 11 1999-11-1
5 Santosh 12 1999-11-1