The DATE function in MariaDB is used to extract the date part of a datetime expression. It returns the date in the format ‘YYYY-MM-DD’. You can use it in the SELECT, WHERE, and ORDER BY clauses.
Here’s a simple syntax example:
```
SELECT DATE FROM table_name;
```
Let’s say for example you have a table called ‘orders’ and there’s a column called ‘order_date’ (which is of datetime type). If you want to retrieve only the date part of ‘order_date’, you can write:
```
SELECT DATE FROM orders;
```
If you want to select records having date part from ‘order\_date’ as ’2022-01-01’, you can write:
```
SELECT * FROM orders WHERE DATE = ’2022-01-01’;
```
Here’s how you’d use it in an ORDER BY clause:
```
SELECT * FROM orders ORDER BY DATE DESC;
```
It will return records ordered based on date part of ‘order\_date’ in descending order.