mysql dates code example

Example 1: mysql date format unix timestamp

SELECT
  FROM_UNIXTIME(timestamp) 
FROM 
  your_table;

Example 2: disallowed function mysql to_date()

mysql> SELECT STR_TO_DATE('18,05,2009','%d,%m,%Y');
+--------------------------------------+
| STR_TO_DATE('18,05,2009','%d,%m,%Y') |
+--------------------------------------+
| 2009-05-18                           | 
+--------------------------------------+
1 row in set (0.00 sec)

Example 3: date mysql

-- sintax of date type in mysql:
-- ' YYYY-MM-DD ' 
SELECT *
FROM table
WHERE date_to_find = '2020-05-25'

Tags:

Sql Example