SQL Date Data Types
SQL Tutorial » SQL Date Data Types
SQL Date Data TypesSQL SELECT DATE is used to retrieve a date from a database.
MySQL comes with the following data types for storing a date or a date/time value in the database:
- DATE - format YYYY-MM-DD example 2021-06-24
- DATETIME - format: YYYY-MM-DD HH:MI:SS 2021-06-24 11:34:46
- TIMESTAMP - format: YYYY-MM-DD HH:MI:SS 2021-06-24 11:34:46
- YEAR - format YYYY or YY 2021 or 21
SQL Server comes with the following data types for storing a date or a date/time value in the database:
- DATE - format YYYY-MM-DD example 2021-06-24
- DATETIME - format: YYYY-MM-DD HH:MI:SS 2021-06-24 11:34:46
- SMALLDATETIME - format: YYYY-MM-DD HH:MI:SS 2021-06-24 11:34:46
- TIMESTAMP - format: a unique number
How to insert a date value in database table
Let's count the entire database (all rows in table) from "Users" first_name", "last_name", "country" and "email":
VALUES ('Chris', 'Ford', 'USA', 'cford@agernic.com','2015-06-24');
Related subjects:
SQL order by
SQL where clause
PHP select / view data
Conect to MySQLi
SQL insert into table
Tags: sql date: format, type, now, between, insert, convert, comparison, time, date type, format dd/mm/yyyy
How do you write a date in SQL query?
What is date command in SQL?
How do I insert date in YYYY-MM-DD format in SQL?
What is the data type of date in SQL?
SQL DATE - get all records between two dates
Let's see the another query to get all the records after '2020-06-22' and before '2022-01-04' date.
WHERE date < '2020-06-22' and date >= '2020-06-21'
SQL DATE - BETWEEN operator
If you want to compare the dates within the query, you should use BETWEEN operator to compare the dates.
WHERE date BETWEEN '2021-12-12' and '2021-12-14'
sql date: format, type, now, between, insert, convert, comparison, time, date type, format dd/mm/yyyy
How do you write a date in SQL query?
What is date command in SQL?
How do I insert date in YYYY-MM-DD format in SQL?
What is the data type of date in SQL?
SQL Date Data Types - sql tutorial
This tool makes it easy to create, adjust, and experiment with custom colors for the web.

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.

Find here examples of creative and unique website layouts.

Find here examples of creative and unique website CSS HTML menu.