SQL Dates
SQL Dates
MySQL comes with the following data types for storing a date or a date/time
value in the database:
Orders Table
1 Geitost 2008-11-11
Now, assume that the "Orders" table looks like this (notice the added time-
component in the "OrderDate" column):
we will get no result! This is because the query is looking only for dates with
no time portion.
Id Name BirthTime
4120 Pratik 1996-09-26 16:44:15.581
SELECT Name, DATE(BirthTime) AS BirthDate FROM Test;
Output:
Name BirthDate
Prati
k 1996-09-26
Queries
SELECT Name, DATE_ADD(BirthTime, INTERVAL 1 YEAR) AS
BirthTimeModified FROM Test;
Output:
Name BirthTimeModified
Prati
k 1997-09-26 16:44:15.581