MySQL Tutorial/Date Time Functions/GET FORMAT

Материал из SQL эксперт
Версия от 09:50, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

GET_FORMAT(DATE,"EUR")

mysql>
mysql> select GET_FORMAT(DATE,"EUR");
+------------------------+
| GET_FORMAT(DATE,"EUR") |
+------------------------+
| %d.%m.%Y               |
+------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATE,"INTERNAL")

mysql>
mysql> select GET_FORMAT(DATE,"INTERNAL");
+-----------------------------+
| GET_FORMAT(DATE,"INTERNAL") |
+-----------------------------+
| %Y%m%d                      |
+-----------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATE,"ISO")

mysql>
mysql> select GET_FORMAT(DATE,"ISO");
+------------------------+
| GET_FORMAT(DATE,"ISO") |
+------------------------+
| %Y-%m-%d               |
+------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATE,"JIS")

mysql>
mysql> select GET_FORMAT(DATE,"JIS");
+------------------------+
| GET_FORMAT(DATE,"JIS") |
+------------------------+
| %Y-%m-%d               |
+------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATE|TIME|DATETIME, "EUR"|"USA"|"JIS"|"ISO"|"INTERNAL")

GET_FORMAT returns the format string used by DATE_FORMAT



mysql>
mysql> select GET_FORMAT(DATE,"USA");
+------------------------+
| GET_FORMAT(DATE,"USA") |
+------------------------+
| %m.%d.%Y               |
+------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATETIME,"EUR")

mysql>
mysql> select GET_FORMAT(DATETIME,"EUR");
+----------------------------+
| GET_FORMAT(DATETIME,"EUR") |
+----------------------------+
| %Y-%m-%d %H.%i.%s          |
+----------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATETIME,"INTERNAL")

mysql>
mysql> select GET_FORMAT(DATETIME,"INTERNAL");
+---------------------------------+
| GET_FORMAT(DATETIME,"INTERNAL") |
+---------------------------------+
| %Y%m%d%H%i%s                    |
+---------------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATETIME,"ISO")

mysql>
mysql> select GET_FORMAT(DATETIME,"ISO");
+----------------------------+
| GET_FORMAT(DATETIME,"ISO") |
+----------------------------+
| %Y-%m-%d %H:%i:%s          |
+----------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATETIME,"JIS")

mysql>
mysql> select GET_FORMAT(DATETIME,"JIS");
+----------------------------+
| GET_FORMAT(DATETIME,"JIS") |
+----------------------------+
| %Y-%m-%d %H:%i:%s          |
+----------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATETIME,"USA")

mysql>
mysql> select GET_FORMAT(DATETIME,"USA");
+----------------------------+
| GET_FORMAT(DATETIME,"USA") |
+----------------------------+
| %Y-%m-%d %H.%i.%s          |
+----------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(DATE,"USA")

mysql>
mysql> select GET_FORMAT(DATE,"USA");
+------------------------+
| GET_FORMAT(DATE,"USA") |
+------------------------+
| %m.%d.%Y               |
+------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(TIME,"EUR")

mysql>
mysql>
mysql> select GET_FORMAT(TIME,"EUR");
+------------------------+
| GET_FORMAT(TIME,"EUR") |
+------------------------+
| %H.%i.%s               |
+------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(TIME,"INTERNAL")

mysql>
mysql> select GET_FORMAT(TIME,"INTERNAL");
+-----------------------------+
| GET_FORMAT(TIME,"INTERNAL") |
+-----------------------------+
| %H%i%s                      |
+-----------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(TIME,"ISO")

mysql>
mysql> select GET_FORMAT(TIME,"ISO");
+------------------------+
| GET_FORMAT(TIME,"ISO") |
+------------------------+
| %H:%i:%s               |
+------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(TIME,"JIS")

mysql>
mysql> select GET_FORMAT(TIME,"JIS");
+------------------------+
| GET_FORMAT(TIME,"JIS") |
+------------------------+
| %H:%i:%s               |
+------------------------+
1 row in set (0.00 sec)
mysql>


GET_FORMAT(TIME,"USA")

mysql>
mysql> select GET_FORMAT(TIME,"USA");
+------------------------+
| GET_FORMAT(TIME,"USA") |
+------------------------+
| %h:%i:%s %p            |
+------------------------+
1 row in set (0.00 sec)
mysql>


SELECT DATE_FORMAT("2003-10-03",GET_FORMAT(DATE,"EUR"));

mysql>
mysql> SELECT DATE_FORMAT("2003-10-03",GET_FORMAT(DATE,"EUR"));
+--------------------------------------------------+
| DATE_FORMAT("2003-10-03",GET_FORMAT(DATE,"EUR")) |
+--------------------------------------------------+
| 03.10.2003                                       |
+--------------------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql>
mysql>


SELECT STR_TO_DATE("10.31.2003",GET_FORMAT(DATE,"USA"));

mysql>
mysql> SELECT STR_TO_DATE("10.31.2003",GET_FORMAT(DATE,"USA"));
+--------------------------------------------------+
| STR_TO_DATE("10.31.2003",GET_FORMAT(DATE,"USA")) |
+--------------------------------------------------+
| 2003-10-31                                       |
+--------------------------------------------------+
1 row in set (0.02 sec)
mysql>