2003-11-03 13:01:59 +01:00
|
|
|
drop table if exists t1;
|
|
|
|
Warnings:
|
|
|
|
Note 1051 Unknown table 't1'
|
2003-10-20 10:24:18 +02:00
|
|
|
SHOW GLOBAL VARIABLES LIKE "%_format%";
|
|
|
|
Variable_name Value
|
|
|
|
date_format %d.%m.%Y
|
2003-11-03 13:01:59 +01:00
|
|
|
datetime_format %Y-%m-%d %H:%i:%s
|
2003-10-20 10:24:18 +02:00
|
|
|
default_week_format 0
|
|
|
|
time_format %H.%i.%s
|
|
|
|
SHOW SESSION VARIABLES LIKE "%_format%";
|
|
|
|
Variable_name Value
|
|
|
|
date_format %d.%m.%Y
|
2003-11-03 13:01:59 +01:00
|
|
|
datetime_format %Y-%m-%d %H:%i:%s
|
2003-10-20 10:24:18 +02:00
|
|
|
default_week_format 0
|
|
|
|
time_format %H.%i.%s
|
2003-11-03 13:01:59 +01:00
|
|
|
SET time_format='%H%i%s';
|
|
|
|
SET time_format='%H:%i:%s.%f';
|
|
|
|
SET time_format='%h-%i-%s.%f%p';
|
|
|
|
SET time_format='%h:%i:%s.%f %p';
|
|
|
|
SET time_format='%h:%i:%s%p';
|
|
|
|
SET date_format='%Y%m%d';
|
|
|
|
SET date_format='%Y.%m.%d';
|
|
|
|
SET date_format='%d.%m.%Y';
|
|
|
|
SET date_format='%m-%d-%Y';
|
|
|
|
set datetime_format= '%Y%m%d%H%i%s';
|
|
|
|
set datetime_format= '%Y-%m-%d %H:%i:%s';
|
|
|
|
set datetime_format= '%m-%d-%y %H:%i:%s.%f';
|
|
|
|
set datetime_format= '%d-%m-%Y %h:%i:%s%p';
|
|
|
|
set datetime_format= '%H:%i:%s %Y-%m-%d';
|
|
|
|
set datetime_format= '%H:%i:%s.%f %m-%d-%Y';
|
|
|
|
set datetime_format= '%h:%i:%s %p %Y-%m-%d';
|
|
|
|
set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
|
|
|
|
SHOW SESSION VARIABLES LIKE "%format";
|
|
|
|
Variable_name Value
|
|
|
|
date_format %m-%d-%Y
|
|
|
|
datetime_format %h:%i:%s.%f %p %Y-%m-%d
|
|
|
|
default_week_format 0
|
|
|
|
time_format %h:%i:%s%p
|
|
|
|
SET time_format='%h:%i:%s';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%h:%i:%s'
|
|
|
|
SET time_format='%H %i:%s';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%H %i:%s'
|
|
|
|
SET time_format='%H::%i:%s';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%H::%i:%s'
|
|
|
|
SET time_format='%H:%i:%s%f';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i:%s%f'
|
|
|
|
SET time_format='%H:%i.%f:%s';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i.%f:%s'
|
|
|
|
SET time_format='%H:%i:%s%p';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i:%s%p'
|
|
|
|
SET time_format='%h:%i:%s.%f %p %Y-%m-%d';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%h:%i:%s.%f %p %Y-%m-%d'
|
|
|
|
SET time_format='%H%i%s.%f';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%H%i%s.%f'
|
|
|
|
SET time_format='%H:%i-%s.%f';
|
|
|
|
ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i-%s.%f'
|
2003-10-20 10:24:18 +02:00
|
|
|
SET date_format='%d.%m.%d';
|
2003-11-03 13:01:59 +01:00
|
|
|
ERROR 42000: Variable 'date_format' can't be set to the value of '%d.%m.%d'
|
|
|
|
SET datetime_format='%h.%m.%y %d.%i.%s';
|
|
|
|
ERROR 42000: Variable 'datetime_format' can't be set to the value of '%h.%m.%y %d.%i.%s'
|
|
|
|
set datetime_format= '%H:%i:%s.%f %p %Y-%m-%d';
|
|
|
|
ERROR 42000: Variable 'datetime_format' can't be set to the value of '%H:%i:%s.%f %p %Y-%m-%d'
|
|
|
|
set GLOBAL datetime_format= '%H:%i:%s %Y-%m-%d';
|
|
|
|
SET SESSION datetime_format=default;
|
|
|
|
select @@global.datetime_format, @@session.datetime_format;
|
|
|
|
@@global.datetime_format @@session.datetime_format
|
|
|
|
%H:%i:%s %Y-%m-%d %H:%i:%s %Y-%m-%d
|
|
|
|
SET GLOBAL datetime_format=default;
|
|
|
|
SET SESSION datetime_format=default;
|
|
|
|
select @@global.datetime_format, @@session.datetime_format;
|
|
|
|
@@global.datetime_format @@session.datetime_format
|
|
|
|
%Y-%m-%d %H:%i:%s %Y-%m-%d %H:%i:%s
|
2003-10-20 10:24:18 +02:00
|
|
|
SET GLOBAL date_format=default;
|
|
|
|
SET GLOBAL time_format=default;
|
|
|
|
SET GLOBAL datetime_format=default;
|
|
|
|
SET time_format=default;
|
2003-11-03 13:01:59 +01:00
|
|
|
SET date_format=default;
|
2003-10-20 10:24:18 +02:00
|
|
|
SET datetime_format=default;
|
2003-11-03 13:01:59 +01:00
|
|
|
select str_to_date(concat('15-01-2001',' 2:59:58.999'),
|
|
|
|
concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
|
|
|
|
str_to_date(concat('15-01-2001',' 2:59:58.999'),
|
|
|
|
concat('%d-%m-%Y',' ','%H:%i:%s.%f'))
|
|
|
|
2001-01-15 02:59:58.000999
|
|
|
|
create table t1 (date char(30), format char(30) not null);
|
|
|
|
insert into t1 values
|
|
|
|
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
|
|
|
|
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S'),
|
|
|
|
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
|
|
|
|
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
|
|
|
|
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
|
|
|
|
('2003-01-02 12:11:12.12345 am', '%Y-%m-%d %h:%i:%S.%f%p'),
|
|
|
|
('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
|
|
|
|
('10:20:10', '%H:%i:%s'),
|
|
|
|
('10:20:10', '%h:%i:%s.%f'),
|
|
|
|
('10:20:10AM', '%h:%i:%s%p'),
|
|
|
|
('10:20:10.44AM', '%h:%i:%s.%f%p'),
|
|
|
|
('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
|
|
|
|
('15 September 2001', '%d %M %Y'),
|
|
|
|
('15 SEPTEMB 2001', '%d %M %Y'),
|
|
|
|
('15 MAY 2001', '%d %b %Y'),
|
|
|
|
('Sunday 15 MAY 2001', '%W %d %b %Y'),
|
|
|
|
('Sund 15 MAY 2001', '%W %d %b %Y'),
|
|
|
|
('Tuesday 00 2002', '%W %U %Y'),
|
|
|
|
('Thursday 53 1998', '%W %u %Y'),
|
|
|
|
('15-01-2001', '%d-%m-%Y %H:%i:%S'),
|
|
|
|
('15-01-20', '%d-%m-%y'),
|
|
|
|
('15-2001-1', '%d-%Y-%c');
|
|
|
|
select date,format,str_to_date(date, format) as str_to_date from t1;
|
|
|
|
date format str_to_date
|
|
|
|
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
|
|
|
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 2003-01-02 08:11:02
|
|
|
|
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
|
|
|
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.012345
|
|
|
|
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.012345
|
|
|
|
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.012345
|
|
|
|
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
|
|
|
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
|
|
|
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
|
|
|
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
|
|
|
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
|
|
|
|
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
|
|
|
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
|
|
|
15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00
|
|
|
|
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
|
|
|
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
|
|
|
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
|
|
|
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
|
|
|
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
|
|
|
select date,format,concat('',str_to_date(date, format)) as con from t1;
|
|
|
|
date format con
|
|
|
|
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
|
|
|
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 2003-01-02 08:11:02
|
|
|
|
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
|
|
|
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.012345
|
|
|
|
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.012345
|
|
|
|
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.012345
|
|
|
|
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
|
|
|
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
|
|
|
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
|
|
|
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
|
|
|
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
|
|
|
|
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
|
|
|
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
|
|
|
15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00
|
|
|
|
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
|
|
|
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
|
|
|
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
|
|
|
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
|
|
|
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
|
|
|
select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
|
|
|
|
date format datetime
|
|
|
|
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
|
|
|
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 2003-01-02 08:11:02
|
|
|
|
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
|
|
|
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.012345
|
|
|
|
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.012345
|
|
|
|
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.012345
|
|
|
|
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
|
|
|
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
|
|
|
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
|
|
|
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
|
|
|
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
|
|
|
|
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
|
|
|
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
|
|
|
15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00
|
|
|
|
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
|
|
|
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
|
|
|
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
|
|
|
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
|
|
|
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
|
|
|
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
|
|
|
select date,format,DATE(str_to_date(date, format)) as date2 from t1;
|
|
|
|
date format date2
|
|
|
|
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02
|
|
|
|
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 2003-01-02
|
|
|
|
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02
|
|
|
|
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
|
|
|
|
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02
|
|
|
|
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
|
|
|
|
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02
|
|
|
|
10:20:10 %H:%i:%s 0000-00-00
|
|
|
|
10:20:10 %h:%i:%s.%f 0000-00-00
|
|
|
|
10:20:10AM %h:%i:%s%p 0000-00-00
|
|
|
|
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00
|
|
|
|
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15
|
|
|
|
15 September 2001 %d %M %Y 2001-09-15
|
|
|
|
15 SEPTEMB 2001 %d %M %Y 2001-01-15
|
|
|
|
15 MAY 2001 %d %b %Y 2001-05-15
|
|
|
|
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15
|
|
|
|
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15
|
|
|
|
Tuesday 00 2002 %W %U %Y 2002-01-01
|
|
|
|
Thursday 53 1998 %W %u %Y 1998-12-31
|
|
|
|
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15
|
|
|
|
15-01-20 %d-%m-%y 2020-01-15
|
|
|
|
15-2001-1 %d-%Y-%c 2001-01-15
|
|
|
|
select date,format,TIME(str_to_date(date, format)) as time from t1;
|
|
|
|
date format time
|
|
|
|
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
|
|
|
|
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 08:11:02
|
|
|
|
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
|
|
|
|
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.012345
|
|
|
|
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.012345
|
|
|
|
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.012345
|
|
|
|
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
|
|
|
|
10:20:10 %H:%i:%s 10:20:10
|
|
|
|
10:20:10 %h:%i:%s.%f 10:20:10
|
|
|
|
10:20:10AM %h:%i:%s%p 10:20:10
|
|
|
|
10:20:10.44AM %h:%i:%s.%f%p 10:20:10.000044
|
|
|
|
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
|
|
|
|
15 September 2001 %d %M %Y 00:00:00
|
|
|
|
15 SEPTEMB 2001 %d %M %Y 00:00:00
|
|
|
|
15 MAY 2001 %d %b %Y 00:00:00
|
|
|
|
Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
|
|
|
|
Sund 15 MAY 2001 %W %d %b %Y 00:00:00
|
|
|
|
Tuesday 00 2002 %W %U %Y 00:00:00
|
|
|
|
Thursday 53 1998 %W %u %Y 00:00:00
|
|
|
|
15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
|
|
|
|
15-01-20 %d-%m-%y 00:00:00
|
|
|
|
15-2001-1 %d-%Y-%c 00:00:00
|
|
|
|
select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
|
|
|
|
date format time2
|
|
|
|
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
|
|
|
|
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 08:11:02
|
|
|
|
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
|
|
|
|
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.012345
|
|
|
|
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.012345
|
|
|
|
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.012345
|
|
|
|
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
|
|
|
|
10:20:10 %H:%i:%s 10:20:10
|
|
|
|
10:20:10 %h:%i:%s.%f 10:20:10
|
|
|
|
10:20:10AM %h:%i:%s%p 10:20:10
|
|
|
|
10:20:10.44AM %h:%i:%s.%f%p 10:20:10.000044
|
|
|
|
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
|
|
|
|
15 September 2001 %d %M %Y 00:00:00
|
|
|
|
15 SEPTEMB 2001 %d %M %Y 00:00:00
|
|
|
|
15 MAY 2001 %d %b %Y 00:00:00
|
|
|
|
Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
|
|
|
|
Sund 15 MAY 2001 %W %d %b %Y 00:00:00
|
|
|
|
Tuesday 00 2002 %W %U %Y 00:00:00
|
|
|
|
Thursday 53 1998 %W %u %Y 00:00:00
|
|
|
|
15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
|
|
|
|
15-01-20 %d-%m-%y 00:00:00
|
|
|
|
15-2001-1 %d-%Y-%c 00:00:00
|
|
|
|
truncate table t1;
|
|
|
|
insert into t1 values
|
|
|
|
('2003-01-02 10:11:12 PM', '%Y-%m-%d %H:%i:%S %p'),
|
|
|
|
('2003-01-02 10:11:12.123456', '%Y-%m-%d %h:%i:%S %p'),
|
|
|
|
('2003-01-02 10:11:12AM', '%Y-%m-%d %h:%i:%S.%f %p'),
|
|
|
|
('2003-01-02 10:11:12AN', '%Y-%m-%d %h:%i:%S%p'),
|
|
|
|
('2003-01-02 10:11:12 PM', '%y-%m-%d %H:%i:%S %p'),
|
|
|
|
('10:20:10AM', '%H:%i:%s%p'),
|
|
|
|
('15 Septembei 2001', '%d %M %Y'),
|
|
|
|
('15 Ju 2001', '%d %M %Y'),
|
|
|
|
('Sund 15 MA', '%W %d %b %Y'),
|
|
|
|
('Sunday 01 2001', '%W %V %X'),
|
|
|
|
('Thursdai 12 1998', '%W %u %Y'),
|
|
|
|
(NULL, get_format(DATE,'USA')),
|
|
|
|
('Tuesday 52 2001', '%W %V %X');
|
|
|
|
select date,format,str_to_date(date, format) as str_to_date from t1;
|
|
|
|
date format str_to_date
|
|
|
|
2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
|
|
|
|
2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
|
|
|
|
2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
|
|
|
|
2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
|
|
|
|
2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
|
|
|
|
10:20:10AM %H:%i:%s%p NULL
|
|
|
|
15 Septembei 2001 %d %M %Y NULL
|
|
|
|
15 Ju 2001 %d %M %Y NULL
|
|
|
|
Sund 15 MA %W %d %b %Y NULL
|
|
|
|
Sunday 01 2001 %W %V %X NULL
|
|
|
|
Thursdai 12 1998 %W %u %Y NULL
|
|
|
|
NULL %m.%d.%Y NULL
|
|
|
|
Tuesday 52 2001 %W %V %X NULL
|
|
|
|
select date,format,concat(str_to_date(date, format),'') as con from t1;
|
|
|
|
date format con
|
|
|
|
2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
|
|
|
|
2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
|
|
|
|
2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
|
|
|
|
2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
|
|
|
|
2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
|
|
|
|
10:20:10AM %H:%i:%s%p NULL
|
|
|
|
15 Septembei 2001 %d %M %Y NULL
|
|
|
|
15 Ju 2001 %d %M %Y NULL
|
|
|
|
Sund 15 MA %W %d %b %Y NULL
|
|
|
|
Sunday 01 2001 %W %V %X NULL
|
|
|
|
Thursdai 12 1998 %W %u %Y NULL
|
|
|
|
NULL %m.%d.%Y NULL
|
|
|
|
Tuesday 52 2001 %W %V %X NULL
|
|
|
|
truncate table t1;
|
|
|
|
insert into t1 values
|
|
|
|
('10:20:10AM', '%h:%i:%s'),
|
|
|
|
('2003-01-02 10:11:12', '%Y-%m-%d %h:%i:%S'),
|
|
|
|
('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
|
|
|
|
select date,format,str_to_date(date, format) as str_to_date from t1;
|
|
|
|
date format str_to_date
|
|
|
|
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
|
|
|
|
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
|
|
|
|
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 0003-01-02 22:11:12
|
|
|
|
select date,format,concat(str_to_date(date, format),'') as con from t1;
|
|
|
|
date format con
|
|
|
|
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
|
|
|
|
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
|
|
|
|
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 0003-01-02 22:11:12
|
|
|
|
drop table t1;
|
2003-10-20 10:24:18 +02:00
|
|
|
select get_format(DATE, 'USA') as a;
|
|
|
|
a
|
|
|
|
%m.%d.%Y
|
|
|
|
select get_format(TIME, 'internal') as a;
|
|
|
|
a
|
|
|
|
%H%i%s
|
|
|
|
select get_format(DATETIME, 'eur') as a;
|
|
|
|
a
|
2003-11-03 13:01:59 +01:00
|
|
|
%Y-%m-%d %H.%i.%s
|
|
|
|
select get_format(DATE, 'TEST') as a;
|
|
|
|
a
|
|
|
|
NULL
|
|
|
|
select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'));
|
|
|
|
str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'))
|
|
|
|
NULL
|
2003-10-30 11:57:26 +01:00
|
|
|
explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001");
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
|
|
|
|
Warnings:
|
|
|
|
Note 1003 select high_priority makedate(1997,1) AS `makedate(1997,1)`,addtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff(_latin1'01.01.97 11:59:59.000001 PM',_latin1'31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date(_latin1'15-01-2001 12:59:59',_latin1'%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond(_latin1'1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")`
|