Date Data type In SQL

Safalta Expert Published by: Saksham Chauhan Updated Tue, 20 Sep 2022 12:35 AM IST

Highlights

Check Date Data type In SQL Here At Safalta.com

Source: Safalta.com

In MySQL, a variety of data types are supported. When storing data values, we may need to use the DATE data type.
When a value has a date component but no time component, the DATE type is utilised. It shows DATE values in the format "YYYY-MM-DD." Any date value that falls between the specified range of "1000-01-01" to "9999-12-31" can be stored. Syntax :  Variable_Name DATE.  Click Here To Download  e-book for MS Excel blog

The examples that follow will show you how to utilise the Date data type in a variable.

Example 1:

 

Establishing a Student

Information table
Student Id, First name, Last name, Date of Birth, Class, and Contact Details columns make up this list. among which the Date Of Birth column's data type is DATE.



Data entry into the Table -


Use the following command as follows to verify.

SELECT * FROM StudentDetails ;

Output :



Therefore, the DATE data-type has been correctly placed in the Date Of Birth Column.

 

Example 2: 

building a table of orders
There are columns for the OrderNumber, OrderDate, ShippedDate, and DeliveryDate. The OrderDate, ShippedDate, and DeliveryDate columns all have the data type DATE.


Inserting data into the Table –


Use the following command as follows to verify.

SELECT * FROM Orders;

Output :