1 echo Create table t1
(f1 timestamp
, f2 timestamp
);
3 Statement Executed
: Rows Affected
= 1
4 Statement Executed
: Rows Affected
= 1
5 Statement Executed
: Rows Affected
= 1
6 Statement Executed
: Rows Affected
= 1
7 Statement Executed
: Rows Affected
= 1
9 ---------------------------------------------------------
11 ---------------------------------------------------------
12 2001/1/1 1:1:1.0 2001/1/5 1:1:1.0
13 2002/1/1 1:1:1.0 2002/4/10 2:2:2.0
14 2003/1/3 1:1:1.0 2003/7/15 12:30:30.0
15 2004/1/1 1:1:1.0 2004/10/20 22:58:58.0
16 2005/1/1 1:1:1.0 2005/12/25 23:59:59.0
18 echo select * from t1 where extract
(year from f2
) =2003;
19 ---------------------------------------------------------
21 ---------------------------------------------------------
22 2003/1/3 1:1:1.0 2003/7/15 12:30:30.0
24 echo select * from t1 where extract
(year from f2
)<=2003;
25 ---------------------------------------------------------
27 ---------------------------------------------------------
28 2001/1/1 1:1:1.0 2001/1/5 1:1:1.0
29 2002/1/1 1:1:1.0 2002/4/10 2:2:2.0
30 2003/1/3 1:1:1.0 2003/7/15 12:30:30.0
32 echo select * from t1 where extract
(year from f2
) >2003;
33 ---------------------------------------------------------
35 ---------------------------------------------------------
36 2004/1/1 1:1:1.0 2004/10/20 22:58:58.0
37 2005/1/1 1:1:1.0 2005/12/25 23:59:59.0
39 echo select * from t1 where extract
(year from f2
)!=2003;
40 ---------------------------------------------------------
42 ---------------------------------------------------------
43 2001/1/1 1:1:1.0 2001/1/5 1:1:1.0
44 2002/1/1 1:1:1.0 2002/4/10 2:2:2.0
45 2004/1/1 1:1:1.0 2004/10/20 22:58:58.0
46 2005/1/1 1:1:1.0 2005/12/25 23:59:59.0
48 echo select * from t1 where extract
(month from f2
) =7;
49 ---------------------------------------------------------
51 ---------------------------------------------------------
52 2003/1/3 1:1:1.0 2003/7/15 12:30:30.0
54 echo select * from t1 where extract
(month from f2
) <7;
55 ---------------------------------------------------------
57 ---------------------------------------------------------
58 2001/1/1 1:1:1.0 2001/1/5 1:1:1.0
59 2002/1/1 1:1:1.0 2002/4/10 2:2:2.0
61 echo select * from t1 where extract
(month from f2
)>=7;
62 ---------------------------------------------------------
64 ---------------------------------------------------------
65 2003/1/3 1:1:1.0 2003/7/15 12:30:30.0
66 2004/1/1 1:1:1.0 2004/10/20 22:58:58.0
67 2005/1/1 1:1:1.0 2005/12/25 23:59:59.0
69 echo select * from t1 where extract
(month from f2
)!=7;
70 ---------------------------------------------------------
72 ---------------------------------------------------------
73 2001/1/1 1:1:1.0 2001/1/5 1:1:1.0
74 2002/1/1 1:1:1.0 2002/4/10 2:2:2.0
75 2004/1/1 1:1:1.0 2004/10/20 22:58:58.0
76 2005/1/1 1:1:1.0 2005/12/25 23:59:59.0
78 echo select * from t1 where extract
(day from f2
) =15;
79 ---------------------------------------------------------
81 ---------------------------------------------------------
82 2003/1/3 1:1:1.0 2003/7/15 12:30:30.0
84 echo select * from t1 where extract
(day from f2
) <15;
85 ---------------------------------------------------------
87 ---------------------------------------------------------
88 2001/1/1 1:1:1.0 2001/1/5 1:1:1.0
89 2002/1/1 1:1:1.0 2002/4/10 2:2:2.0
91 echo select * from t1 where extract
(day from f2
) >15;
92 ---------------------------------------------------------
94 ---------------------------------------------------------
95 2004/1/1 1:1:1.0 2004/10/20 22:58:58.0
96 2005/1/1 1:1:1.0 2005/12/25 23:59:59.0
98 echo select * from t1 where extract
(day from f2
)<>15;
99 ---------------------------------------------------------
101 ---------------------------------------------------------
102 2001/1/1 1:1:1.0 2001/1/5 1:1:1.0
103 2002/1/1 1:1:1.0 2002/4/10 2:2:2.0
104 2004/1/1 1:1:1.0 2004/10/20 22:58:58.0
105 2005/1/1 1:1:1.0 2005/12/25 23:59:59.0