49
45
select makedate(9999,366);
50
46
select makedate(100,1);
54
select addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002");
55
select subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002");
56
select addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
57
select subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
58
select subtime("01:00:00.999999", "02:00:00.999998");
59
select subtime("02:01:01.999999", "01:01:01.999999");
61
# PS doesn't support fractional seconds
63
select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
64
select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
65
select timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002");
66
select timediff("1997-12-31 23:59:59.000001","23:59:59.000001");
67
select timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001");
68
select timediff("2005-01-11 15:48:49.999999", "2005-01-11 15:48:50");
71
select maketime(10,11,12);
72
select maketime(25,11,12);
73
select maketime(-25,11,12);
75
48
# Extraction functions
77
50
# PS doesn't support fractional seconds
78
51
--disable_ps_protocol
79
select timestamp("2001-12-01", "01:01:01.999999");
80
select timestamp("2001-13-01", "01:01:01.000001");
81
select timestamp("2001-12-01", "25:01:01");
82
52
select timestamp("2001-12-01 01:01:01.000100");
83
53
select timestamp("2001-12-01");
84
54
select day("1997-12-31 23:59:59.000001");
85
55
select date("1997-12-31 23:59:59.000001");
86
56
select date("1997-13-31 23:59:59.000001");
87
select time("1997-12-31 23:59:59.000001");
88
select time("1997-12-31 25:59:59.000001");
89
57
select microsecond("1997-12-31 23:59:59.000001");
90
58
--enable_ps_protocol
93
61
select makedate(1997,1) as f1,
94
addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
95
addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
96
timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
97
timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
98
maketime(10,11,12) as f6,
99
timestamp(cast("2001-12-01" as date), "01:01:01") as f7,
100
date("1997-12-31 23:59:59.000001") as f8,
101
time("1997-12-31 23:59:59.000001") as f9;
62
date("1997-12-31 23:59:59.000001") as f8;
103
64
# PS doesn't support fractional seconds
104
65
--disable_ps_protocol
106
67
--enable_ps_protocol
108
create table test(t1 datetime, t2 time, t3 time, t4 datetime);
69
create table test(t1 datetime, t4 datetime);
109
70
insert into test values
110
('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
111
('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"),
112
('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'),
113
('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null),
114
('2001-01-01 01:01:01', '-01:01:01', '1 01:01:01', '2001-01-01 01:01:01'),
115
('2001-01-01 01:01:01', null, '-1 01:01:01', null),
116
(null, null, null, null),
117
('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01');
119
SELECT ADDTIME(t1,t2) As ttt, ADDTIME(t2, t3) As qqq from test;
120
# PS doesn't support fractional seconds
121
--disable_ps_protocol
122
SELECT TIMEDIFF(t1, t4) As ttt, TIMEDIFF(t2, t3) As qqq,
123
TIMEDIFF(t3, t2) As eee, TIMEDIFF(t2, t4) As rrr from test;
71
('2001-01-01 01:01:01', '2001-02-01 01:01:01'),
72
('2001-01-01 01:01:01', "1997-12-31 23:59:59.000001"),
73
('1997-12-31 23:59:59.000001', '2001-01-01 01:01:01'),
74
('2001-01-01 01:01:01', null),
75
('2001-01-01 01:01:01', '2001-01-01 01:01:01'),
76
('2001-01-01 01:01:01', null),
78
('2001-01-01 01:01:01', '2001-01-01 01:01:01');
126
80
drop table t1, test;
128
select addtime("-01:01:01.01", "-23:59:59.1") as a;
129
82
select microsecond("1997-12-31 23:59:59.01") as a;
130
83
select microsecond(19971231235959.01) as a;
131
84
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
132
85
# PS doesn't support fractional seconds
133
--disable_ps_protocol
134
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
137
87
# End of 4.1 tests