SQL Date Function DATE()

www.igift‮i‬dea.com

The DATE() function is a built-in date function in SQL that extracts the date part from a given date or datetime expression. It returns the date portion of a datetime value in the format YYYY-MM-DD.

Here's an example of how to use the DATE() function in a SQL query:

SELECT DATE('2022-03-01 15:30:00');

This query will return the date portion of the given datetime value in the format YYYY-MM-DD, like this:

2022-03-01

You can also use the DATE() function in a WHERE clause to filter records based on a specific date, like this:

SELECT *
FROM my_table
WHERE DATE(date_column) = '2022-03-01';

This query will return all records from my_table where the value in the date_column is equal to the date 2022-03-01.

Note that the DATE() function may have slightly different syntax and behavior depending on the specific SQL database system being used.