Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
92b4f44a
提交
92b4f44a
authored
3月 07, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use >> syntax in scripts/functions/timeanddate
上级
323dab55
隐藏空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
129 行增加
和
355 行删除
+129
-355
add_months.sql
.../org/h2/test/scripts/functions/timeanddate/add_months.sql
+8
-20
dateadd.sql
...est/org/h2/test/scripts/functions/timeanddate/dateadd.sql
+26
-85
datediff.sql
...st/org/h2/test/scripts/functions/timeanddate/datediff.sql
+36
-103
day-of-month.sql
...rg/h2/test/scripts/functions/timeanddate/day-of-month.sql
+2
-5
day-of-week.sql
...org/h2/test/scripts/functions/timeanddate/day-of-week.sql
+2
-5
day-of-year.sql
...org/h2/test/scripts/functions/timeanddate/day-of-year.sql
+1
-4
dayname.sql
...est/org/h2/test/scripts/functions/timeanddate/dayname.sql
+2
-5
extract.sql
...est/org/h2/test/scripts/functions/timeanddate/extract.sql
+17
-29
formatdatetime.sql
.../h2/test/scripts/functions/timeanddate/formatdatetime.sql
+9
-30
hour.sql
...c/test/org/h2/test/scripts/functions/timeanddate/hour.sql
+2
-5
minute.sql
...test/org/h2/test/scripts/functions/timeanddate/minute.sql
+2
-5
month.sql
.../test/org/h2/test/scripts/functions/timeanddate/month.sql
+2
-5
monthname.sql
...t/org/h2/test/scripts/functions/timeanddate/monthname.sql
+2
-5
parsedatetime.sql
...g/h2/test/scripts/functions/timeanddate/parsedatetime.sql
+2
-9
quarter.sql
...est/org/h2/test/scripts/functions/timeanddate/quarter.sql
+2
-5
second.sql
...test/org/h2/test/scripts/functions/timeanddate/second.sql
+2
-5
truncate.sql
...st/org/h2/test/scripts/functions/timeanddate/truncate.sql
+8
-20
week.sql
...c/test/org/h2/test/scripts/functions/timeanddate/week.sql
+2
-5
year.sql
...c/test/org/h2/test/scripts/functions/timeanddate/year.sql
+2
-5
没有找到文件。
h2/src/test/org/h2/test/scripts/functions/timeanddate/add_months.sql
浏览文件 @
92b4f44a
...
...
@@ -4,29 +4,17 @@
--
-- 01-Aug-03 + 3 months = 01-Nov-03
SELECT
ADD_MONTHS
(
'2003-08-01'
,
3
)
AS
R
;
>
R
>
-------------------
>
2003
-
11
-
01
00
:
00
:
00
>
rows
:
1
SELECT
ADD_MONTHS
(
'2003-08-01'
,
3
);
>>
2003
-
11
-
01
00
:
00
:
00
-- 31-Jan-03 + 1 month = 28-Feb-2003
SELECT
ADD_MONTHS
(
'2003-01-31'
,
1
)
AS
R
;
>
R
>
-------------------
>
2003
-
02
-
28
00
:
00
:
00
>
rows
:
1
SELECT
ADD_MONTHS
(
'2003-01-31'
,
1
);
>>
2003
-
02
-
28
00
:
00
:
00
-- 21-Aug-2003 - 3 months = 21-May-2003
SELECT
ADD_MONTHS
(
'2003-08-21'
,
-
3
)
AS
R
;
>
R
>
-------------------
>
2003
-
05
-
21
00
:
00
:
00
>
rows
:
1
SELECT
ADD_MONTHS
(
'2003-08-21'
,
-
3
);
>>
2003
-
05
-
21
00
:
00
:
00
-- 21-Aug-2003 00:00:00.333 - 3 months = 21-May-2003 00:00:00.333
SELECT
ADD_MONTHS
(
'2003-08-21 00:00:00.333'
,
-
3
)
AS
R
;
>
R
>
-----------------------
>
2003
-
05
-
21
00
:
00
:
00
.
333
>
rows
:
1
SELECT
ADD_MONTHS
(
'2003-08-21 00:00:00.333'
,
-
3
);
>>
2003
-
05
-
21
00
:
00
:
00
.
333
h2/src/test/org/h2/test/scripts/functions/timeanddate/dateadd.sql
浏览文件 @
92b4f44a
...
...
@@ -9,17 +9,11 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
dateadd
(
'month'
,
1
,
timestamp
'2003-01-31 10:20:30.012345678'
)
d1
from
test
;
>
D1
>
-----------------------------
>
2003
-
02
-
28
10
:
20
:
30
.
012345678
>
rows
:
1
select
dateadd
(
'month'
,
1
,
timestamp
'2003-01-31 10:20:30.012345678'
)
from
test
;
>>
2003
-
02
-
28
10
:
20
:
30
.
012345678
select
dateadd
(
'year'
,
-
1
,
timestamp
'2000-02-29 10:20:30.012345678'
)
d1
from
test
;
>
D1
>
-----------------------------
>
1999
-
02
-
28
10
:
20
:
30
.
012345678
>
rows
:
1
select
dateadd
(
'year'
,
-
1
,
timestamp
'2000-02-29 10:20:30.012345678'
)
from
test
;
>>
1999
-
02
-
28
10
:
20
:
30
.
012345678
drop
table
test
;
>
ok
...
...
@@ -30,47 +24,26 @@ create table test(d date, t time, ts timestamp);
insert
into
test
values
(
date
'2001-01-01'
,
time
'01:00:00'
,
timestamp
'2010-01-01 00:00:00'
);
>
update
count
:
1
select
ts
+
t
x
from
test
;
>
X
>
-------------------
>
2010
-
01
-
01
01
:
00
:
00
>
rows
:
1
select
ts
+
t
from
test
;
>>
2010
-
01
-
01
01
:
00
:
00
select
ts
+
t
+
t
-
t
x
from
test
;
>
X
>
-------------------
>
2010
-
01
-
01
01
:
00
:
00
>
rows
:
1
>>
2010
-
01
-
01
01
:
00
:
00
select
ts
+
t
*
0
.
5
x
from
test
;
>
X
>
-------------------
>
2010
-
01
-
01
00
:
30
:
00
>
rows
:
1
>>
2010
-
01
-
01
00
:
30
:
00
select
ts
+
0
.
5
x
from
test
;
>
X
>
-------------------
>
2010
-
01
-
01
12
:
00
:
00
>
rows
:
1
>>
2010
-
01
-
01
12
:
00
:
00
select
ts
-
1
.
5
x
from
test
;
>
X
>
-------------------
>
2009
-
12
-
30
12
:
00
:
00
>
rows
:
1
>>
2009
-
12
-
30
12
:
00
:
00
select
ts
+
0
.
5
*
t
+
t
-
t
x
from
test
;
>
X
>
-------------------
>
2010
-
01
-
01
00
:
30
:
00
>
rows
:
1
>>
2010
-
01
-
01
00
:
30
:
00
select
ts
+
t
/
0
.
5
x
from
test
;
>
X
>
-------------------
>
2010
-
01
-
01
02
:
00
:
00
>
rows
:
1
>>
2010
-
01
-
01
02
:
00
:
00
select
d
+
t
,
t
+
d
-
t
x
from
test
;
>
T
+
D
X
...
...
@@ -85,25 +58,16 @@ select 1 + d + 1, d - 1, 2 + ts + 2, ts - 2 from test;
>
rows
:
1
select
1
+
d
+
t
+
1
from
test
;
>
DATEADD
(
'DAY'
,
1
,
(
T
+
DATEADD
(
'DAY'
,
1
,
D
)))
>
---------------------------------------------
>
2001
-
01
-
03
01
:
00
:
00
>
rows
:
1
>>
2001
-
01
-
03
01
:
00
:
00
select
ts
-
t
-
2
from
test
;
>
DATEADD
(
'DAY'
,
-
2
,
(
TS
-
T
))
>
----------------------------
>
2009
-
12
-
29
23
:
00
:
00
>
rows
:
1
>>
2009
-
12
-
29
23
:
00
:
00
drop
table
test
;
>
ok
call
dateadd
(
'MS'
,
1
,
TIMESTAMP
'2001-02-03 04:05:06.789001'
);
>
TIMESTAMP
'2001-02-03 04:05:06.790001'
>
--------------------------------------
>
2001
-
02
-
03
04
:
05
:
06
.
790001
>
rows
:
1
>>
2001
-
02
-
03
04
:
05
:
06
.
790001
SELECT
DATEADD
(
'MICROSECOND'
,
1
,
TIME
'10:00:01'
),
DATEADD
(
'MCS'
,
1
,
TIMESTAMP
'2010-10-20 10:00:01.1'
);
>
TIME
'10:00:01.000001'
TIMESTAMP
'2010-10-20 10:00:01.100001'
...
...
@@ -118,52 +82,29 @@ SELECT DATEADD('NANOSECOND', 1, TIME '10:00:01'), DATEADD('NS', 1, TIMESTAMP '20
>
rows
:
1
SELECT
DATEADD
(
'HOUR'
,
1
,
DATE
'2010-01-20'
);
>
TIMESTAMP
'2010-01-20 01:00:00'
>
-------------------------------
>
2010
-
01
-
20
01
:
00
:
00
>
rows
:
1
>>
2010
-
01
-
20
01
:
00
:
00
SELECT
DATEADD
(
'MINUTE'
,
30
,
TIME
'12:30:55'
);
>
TIME
'13:00:55'
>
---------------
>
13
:
00
:
55
>
rows
:
1
>>
13
:
00
:
55
SELECT
DATEADD
(
'DAY'
,
1
,
TIME
'12:30:55'
);
>
exception
SELECT
DATEADD
(
'QUARTER'
,
1
,
DATE
'2010-11-16'
);
>
DATE
'2011-02-16'
>
-----------------
>
2011
-
02
-
16
>
rows
:
1
>>
2011
-
02
-
16
SELECT
DATEADD
(
'DAY'
,
10
,
TIMESTAMP
WITH
TIME
ZONE
'2000-01-05 15:00:30.123456789-10'
);
>
TIMESTAMP
WITH
TIME
ZONE
'2000-01-15 15:00:30.123456789-10'
>
-----------------------------------------------------------
>
2000
-
01
-
15
15
:
00
:
30
.
123456789
-
10
>
rows
:
1
>>
2000
-
01
-
15
15
:
00
:
30
.
123456789
-
10
SELECT
TIMESTAMPADD
(
'DAY'
,
10
,
TIMESTAMP
'2000-01-05 15:00:30.123456789'
);
>
TIMESTAMP
'2000-01-15 15:00:30.123456789'
>
-----------------------------------------
>
2000
-
01
-
15
15
:
00
:
30
.
123456789
>
rows
:
1
>>
2000
-
01
-
15
15
:
00
:
30
.
123456789
SELECT
TIMESTAMPADD
(
'TIMEZONE_HOUR'
,
1
,
TIMESTAMP
WITH
TIME
ZONE
'2010-01-01 10:00:00+07:30'
)
AS
T
;
>
T
>
-------------------------
>
2010
-
01
-
01
10
:
00
:
00
+
08
:
30
>
rows
:
1
SELECT
TIMESTAMPADD
(
'TIMEZONE_HOUR'
,
1
,
TIMESTAMP
WITH
TIME
ZONE
'2010-01-01 10:00:00+07:30'
);
>>
2010
-
01
-
01
10
:
00
:
00
+
08
:
30
SELECT
TIMESTAMPADD
(
'TIMEZONE_MINUTE'
,
-
45
,
TIMESTAMP
WITH
TIME
ZONE
'2010-01-01 10:00:00+07:30'
)
AS
T
;
>
T
>
-------------------------
>
2010
-
01
-
01
10
:
00
:
00
+
06
:
45
>
rows
:
1
SELECT
TIMESTAMPADD
(
'TIMEZONE_MINUTE'
,
-
45
,
TIMESTAMP
WITH
TIME
ZONE
'2010-01-01 10:00:00+07:30'
);
>>
2010
-
01
-
01
10
:
00
:
00
+
06
:
45
SELECT
DATEADD
(
HOUR
,
1
,
TIME
'23:00:00'
)
AS
T
;
>
T
>
--------
>
00
:
00
:
00
SELECT
DATEADD
(
HOUR
,
1
,
TIME
'23:00:00'
);
>>
00
:
00
:
00
>
rows
:
1
h2/src/test/org/h2/test/scripts/functions/timeanddate/datediff.sql
浏览文件 @
92b4f44a
...
...
@@ -9,89 +9,47 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
datediff
(
'yy'
,
timestamp
'2003-12-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
d1
from
test
;
>
D1
>
--
>
1
>
rows
:
1
select
datediff
(
'yy'
,
timestamp
'2003-12-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
from
test
;
>>
1
select
datediff
(
'year'
,
timestamp
'2003-12-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
d1
from
test
;
>
D1
>
--
>
1
>
rows
:
1
select
datediff
(
'year'
,
timestamp
'2003-12-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
from
test
;
>>
1
select
datediff
(
'mm'
,
timestamp
'2003-11-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
d2
from
test
;
>
D2
>
--
>
2
>
rows
:
1
select
datediff
(
'mm'
,
timestamp
'2003-11-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
from
test
;
>>
2
select
datediff
(
'month'
,
timestamp
'2003-11-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
d2
from
test
;
>
D2
>
--
>
2
>
rows
:
1
select
datediff
(
'month'
,
timestamp
'2003-11-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
from
test
;
>>
2
select
datediff
(
'dd'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-05 10:00:00.0'
)
d4
from
test
;
>
D4
>
--
>
4
>
rows
:
1
select
datediff
(
'dd'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-05 10:00:00.0'
)
from
test
;
>>
4
select
datediff
(
'day'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-05 10:00:00.0'
)
d4
from
test
;
>
D4
>
--
>
4
>
rows
:
1
select
datediff
(
'day'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-05 10:00:00.0'
)
from
test
;
>>
4
select
datediff
(
'hh'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-02 10:00:00.0'
)
d24
from
test
;
>
D24
>
---
>
24
>
rows
:
1
select
datediff
(
'hh'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-02 10:00:00.0'
)
from
test
;
>>
24
select
datediff
(
'hour'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-02 10:00:00.0'
)
d24
from
test
;
>
D24
>
---
>
24
>
rows
:
1
select
datediff
(
'hour'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-02 10:00:00.0'
)
from
test
;
>>
24
select
datediff
(
'mi'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
d20
from
test
;
>
D20
>
---
>
-
20
>
rows
:
1
select
datediff
(
'mi'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
from
test
;
>>
-
20
select
datediff
(
'minute'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
d20
from
test
;
>
D20
>
---
>
-
20
>
rows
:
1
select
datediff
(
'minute'
,
timestamp
'2004-01-01 10:20:30.0'
,
timestamp
'2004-01-01 10:00:00.0'
)
from
test
;
>>
-
20
select
datediff
(
'ss'
,
timestamp
'2004-01-01 10:00:00.5'
,
timestamp
'2004-01-01 10:00:01.0'
)
d1
from
test
;
>
D1
>
--
>
1
>
rows
:
1
select
datediff
(
'ss'
,
timestamp
'2004-01-01 10:00:00.5'
,
timestamp
'2004-01-01 10:00:01.0'
)
from
test
;
>>
1
select
datediff
(
'second'
,
timestamp
'2004-01-01 10:00:00.5'
,
timestamp
'2004-01-01 10:00:01.0'
)
d1
from
test
;
>
D1
>
--
>
1
>
rows
:
1
select
datediff
(
'second'
,
timestamp
'2004-01-01 10:00:00.5'
,
timestamp
'2004-01-01 10:00:01.0'
)
from
test
;
>>
1
select
datediff
(
'ms'
,
timestamp
'2004-01-01 10:00:00.5'
,
timestamp
'2004-01-01 10:00:01.0'
)
d50x
from
test
;
>
D50X
>
----
>
500
>
rows
:
1
select
datediff
(
'ms'
,
timestamp
'2004-01-01 10:00:00.5'
,
timestamp
'2004-01-01 10:00:01.0'
)
from
test
;
>>
500
select
datediff
(
'millisecond'
,
timestamp
'2004-01-01 10:00:00.5'
,
timestamp
'2004-01-01 10:00:01.0'
)
d50x
from
test
;
>
D50X
>
----
>
500
>
rows
:
1
select
datediff
(
'millisecond'
,
timestamp
'2004-01-01 10:00:00.5'
,
timestamp
'2004-01-01 10:00:01.0'
)
from
test
;
>>
500
SELECT
DATEDIFF
(
'SECOND'
,
'1900-01-01 00:00:00.001'
,
'1900-01-01 00:00:00.002'
),
DATEDIFF
(
'SECOND'
,
'2000-01-01 00:00:00.001'
,
'2000-01-01 00:00:00.002'
);
>
0
0
...
...
@@ -154,10 +112,7 @@ call datediff('MS', TIMESTAMP '2001-02-03 04:05:06.789001', TIMESTAMP '2001-02-0
>
rows
:
1
call
datediff
(
'MS'
,
TIMESTAMP
'1900-01-01 00:00:01.000'
,
TIMESTAMP
'2008-01-01 00:00:00.000'
);
>
3408134399000
>
-------------
>
3408134399000
>
rows
:
1
>>
3408134399000
SELECT
DATEDIFF
(
'MICROSECOND'
,
'2006-01-01 00:00:00.0000000'
,
'2006-01-01 00:00:00.123456789'
),
DATEDIFF
(
'MCS'
,
'2006-01-01 00:00:00.0000000'
,
'2006-01-01 00:00:00.123456789'
),
...
...
@@ -212,46 +167,24 @@ SELECT DATEDIFF('WEEK', DATE '1969-12-28', DATE '1969-12-29'), DATEDIFF('ISO_WEE
>
rows
:
1
SELECT
DATEDIFF
(
'QUARTER'
,
DATE
'2009-12-30'
,
DATE
'2009-12-31'
);
>
0
>
-
>
0
>
rows
:
1
>>
0
SELECT
DATEDIFF
(
'QUARTER'
,
DATE
'2010-01-01'
,
DATE
'2009-12-31'
);
>
-
1
>
--
>
-
1
>
rows
:
1
>>
-
1
SELECT
DATEDIFF
(
'QUARTER'
,
DATE
'2010-01-01'
,
DATE
'2010-01-02'
);
>
0
>
-
>
0
>
rows
:
1
>>
0
SELECT
DATEDIFF
(
'QUARTER'
,
DATE
'2010-01-01'
,
DATE
'2010-03-31'
);
>
0
>
-
>
0
>
rows
:
1
>>
0
SELECT
DATEDIFF
(
'QUARTER'
,
DATE
'-1000-01-01'
,
DATE
'2000-01-01'
);
>
12000
>
-----
>
12000
>
rows
:
1
>>
12000
SELECT
DATEDIFF
(
'TIMEZONE_HOUR'
,
TIMESTAMP
WITH
TIME
ZONE
'2010-01-01 10:00:00+01'
,
TIMESTAMP
WITH
TIME
ZONE
'2012-02-02 12:00:00+02'
);
>
1
>
-
>
1
>
rows
:
1
>>
1
SELECT
DATEDIFF
(
'TIMEZONE_MINUTE'
,
TIMESTAMP
WITH
TIME
ZONE
'2010-01-01 10:00:00+01:15'
,
TIMESTAMP
WITH
TIME
ZONE
'2012-02-02 12:00:00+02'
);
>
45
>
--
>
45
>
rows
:
1
>>
45
h2/src/test/org/h2/test/scripts/functions/timeanddate/day-of-month.sql
浏览文件 @
92b4f44a
...
...
@@ -9,11 +9,8 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
dayofmonth
(
date
'2005-09-12'
)
d12
from
test
;
>
D12
>
---
>
12
>
rows
:
1
select
dayofmonth
(
date
'2005-09-12'
)
from
test
;
>>
12
drop
table
test
;
>
ok
...
...
h2/src/test/org/h2/test/scripts/functions/timeanddate/day-of-week.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
dayofweek
(
date
'2005-09-12'
)
d2
from
test
;
>
D2
>
--
>
2
>
rows
:
1
select
dayofweek
(
date
'2005-09-12'
)
from
test
;
>>
2
h2/src/test/org/h2/test/scripts/functions/timeanddate/day-of-year.sql
浏览文件 @
92b4f44a
...
...
@@ -10,7 +10,4 @@ insert into test values(1, 'Hello');
>
update
count
:
1
select
dayofyear
(
date
'2005-01-01'
)
d1
from
test
;
>
D1
>
--
>
1
>
rows
:
1
>>
1
h2/src/test/org/h2/test/scripts/functions/timeanddate/dayname.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
dayname
(
date
'2005-09-12'
)
d_monday
from
test
;
>
D_MONDAY
>
--------
>
Monday
>
rows
:
1
select
dayname
(
date
'2005-09-12'
)
from
test
;
>>
Monday
h2/src/test/org/h2/test/scripts/functions/timeanddate/extract.sql
浏览文件 @
92b4f44a
...
...
@@ -18,64 +18,52 @@ SELECT EXTRACT (NANOSECOND FROM TIME '10:00:00.123456789'),
>
rows
:
1
select
EXTRACT
(
EPOCH
from
time
'00:00:00'
);
>
0
>
>
0
select
EXTRACT
(
EPOCH
from
time
'10:00:00'
);
>
36000
>
>
36000
select
EXTRACT
(
EPOCH
from
time
'10:00:00.123456'
);
>
36000
.
123456
>
>
36000
.
123456
select
EXTRACT
(
EPOCH
from
date
'1970-01-01'
);
>
0
>
>
0
select
EXTRACT
(
EPOCH
from
date
'2000-01-03'
);
>
946857600
>
>
946857600
select
EXTRACT
(
EPOCH
from
timestamp
'1970-01-01 00:00:00'
);
>
0
>
>
0
select
EXTRACT
(
EPOCH
from
timestamp
'1970-01-03 12:00:00.123456'
);
>
216000
.
123456
>
>
216000
.
123456
select
EXTRACT
(
EPOCH
from
timestamp
'2000-01-03 12:00:00.123456'
);
>
946900800
.
123456
>
>
946900800
.
123456
select
EXTRACT
(
EPOCH
from
timestamp
'2500-01-03 12:00:00.654321'
);
>
16725441600
.
654321
>
>
16725441600
.
654321
select
EXTRACT
(
EPOCH
from
timestamp
with
time
zone
'1970-01-01 00:00:00+05'
);
>
-
18000
>
>
-
18000
select
EXTRACT
(
EPOCH
from
timestamp
with
time
zone
'1970-01-03 12:00:00.123456+05'
);
>
198000
.
123456
>
>
198000
.
123456
select
EXTRACT
(
EPOCH
from
timestamp
with
time
zone
'2000-01-03 12:00:00.123456+05'
);
>
946882800
.
123456
>
>
946882800
.
123456
select
extract
(
EPOCH
from
'2001-02-03 14:15:16'
);
>
981209716
>
>
981209716
SELECT
EXTRACT
(
TIMEZONE_HOUR
FROM
TIMESTAMP
WITH
TIME
ZONE
'2010-01-02 5:00:00+07:15'
);
>
7
>
-
>
7
>
rows
:
1
>>
7
SELECT
EXTRACT
(
TIMEZONE_HOUR
FROM
TIMESTAMP
WITH
TIME
ZONE
'2010-01-02 5:00:00-08:30'
);
>
-
8
>
--
>
-
8
>
rows
:
1
>>
-
8
SELECT
EXTRACT
(
TIMEZONE_MINUTE
FROM
TIMESTAMP
WITH
TIME
ZONE
'2010-01-02 5:00:00+07:15'
);
>
15
>
--
>
15
>
rows
:
1
>>
15
SELECT
EXTRACT
(
TIMEZONE_MINUTE
FROM
TIMESTAMP
WITH
TIME
ZONE
'2010-01-02 5:00:00-08:30'
);
>
-
30
>
---
>
-
30
>
rows
:
1
>>
-
30
h2/src/test/org/h2/test/scripts/functions/timeanddate/formatdatetime.sql
浏览文件 @
92b4f44a
...
...
@@ -4,43 +4,22 @@
--
CALL
FORMATDATETIME
(
PARSEDATETIME
(
'2001-02-03 04:05:06 GMT'
,
'yyyy-MM-dd HH:mm:ss z'
,
'en'
,
'GMT'
),
'EEE, d MMM yyyy HH:mm:ss z'
,
'en'
,
'GMT'
);
>
'Sat, 3 Feb 2001 04:05:06 GMT'
>
------------------------------
>
Sat
,
3
Feb
2001
04
:
05
:
06
GMT
>
rows
:
1
>>
Sat
,
3
Feb
2001
04
:
05
:
06
GMT
CALL
FORMATDATETIME
(
TIMESTAMP
'2001-02-03 04:05:06'
,
'yyyy-MM-dd HH:mm:ss'
);
>
'2001-02-03 04:05:06'
>
---------------------
>
2001
-
02
-
03
04
:
05
:
06
>
rows
:
1
>>
2001
-
02
-
03
04
:
05
:
06
CALL
FORMATDATETIME
(
TIMESTAMP
'2001-02-03 04:05:06'
,
'MM/dd/yyyy HH:mm:ss'
);
>
'02/03/2001 04:05:06'
>
---------------------
>
02
/
03
/
2001
04
:
05
:
06
>
rows
:
1
>>
02
/
03
/
2001
04
:
05
:
06
CALL
FORMATDATETIME
(
TIMESTAMP
'2001-02-03 04:05:06'
,
'd. MMMM yyyy'
,
'de'
);
>
'3. Februar 2001'
>
-----------------
>
3
.
Februar
2001
>
rows
:
1
>>
3
.
Februar
2001
CALL
FORMATDATETIME
(
PARSEDATETIME
(
'Sat, 3 Feb 2001 04:05:06 GMT'
,
'EEE, d MMM yyyy HH:mm:ss z'
,
'en'
,
'GMT'
),
'yyyy-MM-dd HH:mm:ss'
,
'en'
,
'GMT'
);
>
'2001-02-03 04:05:06'
>
---------------------
>
2001
-
02
-
03
04
:
05
:
06
>
rows
:
1
>>
2001
-
02
-
03
04
:
05
:
06
SELECT
FORMATDATETIME
(
TIMESTAMP
WITH
TIME
ZONE
'2010-05-06 07:08:09.123Z'
,
'yyyy-MM-dd HH:mm:ss.SSS z'
)
AS
S
;
>
S
>
---------------------------
>
2010
-
05
-
06
07
:
08
:
09
.
123
UTC
>
rows
:
1
SELECT
FORMATDATETIME
(
TIMESTAMP
WITH
TIME
ZONE
'2010-05-06 07:08:09.123Z'
,
'yyyy-MM-dd HH:mm:ss.SSS z'
);
>>
2010
-
05
-
06
07
:
08
:
09
.
123
UTC
SELECT
FORMATDATETIME
(
TIMESTAMP
WITH
TIME
ZONE
'2010-05-06 07:08:09.123+13:30'
,
'yyyy-MM-dd HH:mm:ss.SSS z'
)
AS
S
;
>
S
>
---------------------------------
>
2010
-
05
-
06
07
:
08
:
09
.
123
GMT
+
13
:
30
>
rows
:
1
SELECT
FORMATDATETIME
(
TIMESTAMP
WITH
TIME
ZONE
'2010-05-06 07:08:09.123+13:30'
,
'yyyy-MM-dd HH:mm:ss.SSS z'
);
>>
2010
-
05
-
06
07
:
08
:
09
.
123
GMT
+
13
:
30
h2/src/test/org/h2/test/scripts/functions/timeanddate/hour.sql
浏览文件 @
92b4f44a
...
...
@@ -9,11 +9,8 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
hour
(
time
'23:10:59'
)
d23
from
test
;
>
D23
>
---
>
23
>
rows
:
1
select
hour
(
time
'23:10:59'
)
from
test
;
>>
23
drop
table
test
;
>
ok
...
...
h2/src/test/org/h2/test/scripts/functions/timeanddate/minute.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
minute
(
timestamp
'2005-01-01 23:10:59'
)
d10
from
test
;
>
D10
>
---
>
10
>
rows
:
1
select
minute
(
timestamp
'2005-01-01 23:10:59'
)
from
test
;
>>
10
h2/src/test/org/h2/test/scripts/functions/timeanddate/month.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
month
(
date
'2005-09-25'
)
d9
from
test
;
>
D9
>
--
>
9
>
rows
:
1
select
month
(
date
'2005-09-25'
)
from
test
;
>>
9
h2/src/test/org/h2/test/scripts/functions/timeanddate/monthname.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
monthname
(
date
'2005-09-12'
)
d_sept
from
test
;
>
D_SEPT
>
---------
>
September
>
rows
:
1
select
monthname
(
date
'2005-09-12'
)
from
test
;
>>
September
h2/src/test/org/h2/test/scripts/functions/timeanddate/parsedatetime.sql
浏览文件 @
92b4f44a
...
...
@@ -4,14 +4,7 @@
--
CALL
PARSEDATETIME
(
'3. Februar 2001'
,
'd. MMMM yyyy'
,
'de'
);
>
TIMESTAMP
'2001-02-03 00:00:00'
>
-------------------------------
>
2001
-
02
-
03
00
:
00
:
00
>
rows
:
1
>>
2001
-
02
-
03
00
:
00
:
00
CALL
PARSEDATETIME
(
'02/03/2001 04:05:06'
,
'MM/dd/yyyy HH:mm:ss'
);
>
TIMESTAMP
'2001-02-03 04:05:06'
>
-------------------------------
>
2001
-
02
-
03
04
:
05
:
06
>
rows
:
1
>>
2001
-
02
-
03
04
:
05
:
06
h2/src/test/org/h2/test/scripts/functions/timeanddate/quarter.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
quarter
(
date
'2005-09-01'
)
d3
from
test
;
>
D3
>
--
>
3
>
rows
:
1
select
quarter
(
date
'2005-09-01'
)
from
test
;
>>
3
h2/src/test/org/h2/test/scripts/functions/timeanddate/second.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
second
(
timestamp
'2005-01-01 23:10:59'
)
d59
from
test
;
>
D59
>
---
>
59
>
rows
:
1
select
second
(
timestamp
'2005-01-01 23:10:59'
)
from
test
;
>>
59
h2/src/test/org/h2/test/scripts/functions/timeanddate/truncate.sql
浏览文件 @
92b4f44a
...
...
@@ -3,26 +3,14 @@
-- Initial Developer: H2 Group
--
select
trunc
(
'2015-05-29 15:00:00'
)
R
;
>
R
>
-------------------
>
2015
-
05
-
29
00
:
00
:
00
>
rows
:
1
select
trunc
(
'2015-05-29 15:00:00'
);
>>
2015
-
05
-
29
00
:
00
:
00
select
trunc
(
'2015-05-29'
)
R
;
>
R
>
-------------------
>
2015
-
05
-
29
00
:
00
:
00
>
rows
:
1
select
trunc
(
'2015-05-29'
);
>>
2015
-
05
-
29
00
:
00
:
00
select
trunc
(
timestamp
'2000-01-01 10:20:30.0'
)
R
;
>
R
>
-------------------
>
2000
-
01
-
01
00
:
00
:
00
>
rows
:
1
select
trunc
(
timestamp
'2000-01-01 10:20:30.0'
);
>>
2000
-
01
-
01
00
:
00
:
00
select
trunc
(
timestamp
'2001-01-01 14:00:00.0'
)
R
;
>
R
>
-------------------
>
2001
-
01
-
01
00
:
00
:
00
>
rows
:
1
select
trunc
(
timestamp
'2001-01-01 14:00:00.0'
);
>>
2001
-
01
-
01
00
:
00
:
00
h2/src/test/org/h2/test/scripts/functions/timeanddate/week.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
week
(
date
'2003-01-09'
)
d1
from
test
;
>
D1
>
--
>
2
>
rows
:
1
select
week
(
date
'2003-01-09'
)
from
test
;
>>
2
h2/src/test/org/h2/test/scripts/functions/timeanddate/year.sql
浏览文件 @
92b4f44a
...
...
@@ -9,8 +9,5 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
select
year
(
date
'2005-01-01'
)
d2005
from
test
;
>
D2005
>
-----
>
2005
>
rows
:
1
select
year
(
date
'2005-01-01'
)
from
test
;
>>
2005
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论