func_sapdb.result
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:9k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. drop table if exists t1, test;
  2. select extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123");
  3. extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123")
  4. 2101112000123
  5. select extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123");
  6. extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123")
  7. 101112000123
  8. select extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123");
  9. extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123")
  10. 1112000123
  11. select extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123");
  12. extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123")
  13. 12000123
  14. select extract(MICROSECOND FROM "1999-01-02 10:11:12.000123");
  15. extract(MICROSECOND FROM "1999-01-02 10:11:12.000123")
  16. 123
  17. select date_format("1997-12-31 23:59:59.000002", "%f");
  18. date_format("1997-12-31 23:59:59.000002", "%f")
  19. 000002
  20. select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND);
  21. date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND)
  22. 2025-05-23 04:40:39.000001
  23. select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND);
  24. date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND)
  25. 1999-02-21 17:40:39.000001
  26. select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND);
  27. date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND)
  28. 1998-01-07 22:41:39.000001
  29. select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND);
  30. date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND)
  31. 1998-01-01 02:46:40.000001
  32. select date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND);
  33. date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND)
  34. 1998-01-01 00:00:00.000001
  35. select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND);
  36. date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND)
  37. 1997-12-30 22:58:58.999999
  38. select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND);
  39. date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND)
  40. 1997-12-31 22:58:58.999999
  41. select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND);
  42. date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND)
  43. 1997-12-31 23:58:58.999999
  44. select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND);
  45. date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND)
  46. 1997-12-31 23:59:58.999999
  47. select date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND);
  48. date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND)
  49. 1997-12-31 23:59:59.999999
  50. select adddate("1997-12-31 23:59:59.000001", 10);
  51. adddate("1997-12-31 23:59:59.000001", 10)
  52. 1998-01-10 23:59:59.000001
  53. select subdate("1997-12-31 23:59:59.000001", 10);
  54. subdate("1997-12-31 23:59:59.000001", 10)
  55. 1997-12-21 23:59:59.000001
  56. select datediff("1997-12-31 23:59:59.000001","1997-12-30");
  57. datediff("1997-12-31 23:59:59.000001","1997-12-30")
  58. 1
  59. select datediff("1997-11-31 23:59:59.000001","1997-12-31");
  60. datediff("1997-11-31 23:59:59.000001","1997-12-31")
  61. -30
  62. select datediff("1997-11-31 23:59:59.000001",null);
  63. datediff("1997-11-31 23:59:59.000001",null)
  64. NULL
  65. select weekofyear("1997-11-31 23:59:59.000001");
  66. weekofyear("1997-11-31 23:59:59.000001")
  67. 49
  68. select makedate(1997,1);
  69. makedate(1997,1)
  70. 1997-01-01
  71. select makedate(1997,0);
  72. makedate(1997,0)
  73. NULL
  74. select addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002");
  75. addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002")
  76. 1998-01-02 01:01:01.000001
  77. select subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002");
  78. subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002")
  79. 1997-12-30 22:58:57.999999
  80. select addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
  81. addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
  82. NULL
  83. select subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
  84. subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
  85. NULL
  86. select subtime("01:00:00.999999", "02:00:00.999998");
  87. subtime("01:00:00.999999", "02:00:00.999998")
  88. -00:59:59.999999
  89. select subtime("02:01:01.999999", "01:01:01.999999");
  90. subtime("02:01:01.999999", "01:01:01.999999")
  91. 01:00:00.000000
  92. select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
  93. timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002")
  94. 8807:59:59.999999
  95. select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
  96. timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002")
  97. 46:58:57.999999
  98. select timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002");
  99. timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002")
  100. -24:00:00.000001
  101. select timediff("1997-12-31 23:59:59.000001","23:59:59.000001");
  102. timediff("1997-12-31 23:59:59.000001","23:59:59.000001")
  103. NULL
  104. select timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001");
  105. timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001")
  106. -00:00:00.000001
  107. select timediff("2005-01-11 15:48:49.999999", "2005-01-11 15:48:50");
  108. timediff("2005-01-11 15:48:49.999999", "2005-01-11 15:48:50")
  109. -00:00:00.000001
  110. select maketime(10,11,12);
  111. maketime(10,11,12)
  112. 10:11:12
  113. select maketime(25,11,12);
  114. maketime(25,11,12)
  115. 25:11:12
  116. select maketime(-25,11,12);
  117. maketime(-25,11,12)
  118. -25:11:12
  119. select timestamp("2001-12-01", "01:01:01.999999");
  120. timestamp("2001-12-01", "01:01:01.999999")
  121. 2001-12-01 01:01:01.999999
  122. select timestamp("2001-13-01", "01:01:01.000001");
  123. timestamp("2001-13-01", "01:01:01.000001")
  124. NULL
  125. Warnings:
  126. Warning 1292 Truncated incorrect datetime value: '2001-13-01'
  127. select timestamp("2001-12-01", "25:01:01");
  128. timestamp("2001-12-01", "25:01:01")
  129. 2001-12-02 01:01:01
  130. select timestamp("2001-12-01 01:01:01.000100");
  131. timestamp("2001-12-01 01:01:01.000100")
  132. 2001-12-01 01:01:01.000100
  133. select timestamp("2001-12-01");
  134. timestamp("2001-12-01")
  135. 2001-12-01 00:00:00
  136. select day("1997-12-31 23:59:59.000001");
  137. day("1997-12-31 23:59:59.000001")
  138. 31
  139. select date("1997-12-31 23:59:59.000001");
  140. date("1997-12-31 23:59:59.000001")
  141. 1997-12-31
  142. select date("1997-13-31 23:59:59.000001");
  143. date("1997-13-31 23:59:59.000001")
  144. NULL
  145. Warnings:
  146. Warning 1292 Truncated incorrect datetime value: '1997-13-31 23:59:59.000001'
  147. select time("1997-12-31 23:59:59.000001");
  148. time("1997-12-31 23:59:59.000001")
  149. 23:59:59.000001
  150. select time("1997-12-31 25:59:59.000001");
  151. time("1997-12-31 25:59:59.000001")
  152. NULL
  153. Warnings:
  154. Warning 1292 Truncated incorrect time value: '1997-12-31 25:59:59.000001'
  155. select microsecond("1997-12-31 23:59:59.000001");
  156. microsecond("1997-12-31 23:59:59.000001")
  157. 1
  158. create table t1 
  159. select makedate(1997,1) as f1,
  160. addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
  161. addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
  162. timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
  163. timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
  164. maketime(10,11,12) as f6,
  165. timestamp(cast("2001-12-01" as date), "01:01:01") as f7,
  166. date("1997-12-31 23:59:59.000001") as f8,
  167. time("1997-12-31 23:59:59.000001") as f9;
  168. describe t1;
  169. Field Type Null Key Default Extra
  170. f1 date 0000-00-00
  171. f2 datetime YES NULL
  172. f3 time YES NULL
  173. f4 time YES NULL
  174. f5 time YES NULL
  175. f6 time 00:00:00
  176. f7 datetime YES NULL
  177. f8 date YES NULL
  178. f9 time YES NULL
  179. select * from t1;
  180. f1 f2 f3 f4 f5 f6 f7 f8 f9
  181. 1997-01-01 1998-01-02 01:01:00 49:01:01 46:58:57 -24:00:00 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59
  182. create table test(t1 datetime, t2 time, t3 time, t4 datetime);
  183. insert into test values 
  184. ('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
  185. ('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"),
  186. ('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'),
  187. ('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null),
  188. ('2001-01-01 01:01:01', '-01:01:01', '1 01:01:01', '2001-01-01 01:01:01'),
  189. ('2001-01-01 01:01:01', null, '-1 01:01:01', null),
  190. (null, null, null, null),
  191. ('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01');
  192. SELECT ADDTIME(t1,t2) As ttt, ADDTIME(t2, t3) As qqq from test;
  193. ttt qqq
  194. 2001-01-01 02:02:02 NULL
  195. 2001-01-01 00:00:00 -25:01:00
  196. 1997-12-31 00:00:00 -25:01:00
  197. 2001-01-01 02:02:02 -24:00:00
  198. 2001-01-01 00:00:00 24:00:00
  199. NULL NULL
  200. NULL NULL
  201. 2001-01-01 02:02:02 26:02:02
  202. SELECT TIMEDIFF(t1,t4) As ttt, TIMEDIFF(t2, t3) As qqq from test;
  203. ttt qqq
  204. -744:00:00 NULL
  205. 26305:01:02 22:58:58
  206. -26305:01:02 -22:58:58
  207. NULL 26:02:02
  208. 00:00:00 -26:02:02
  209. NULL NULL
  210. NULL NULL
  211. 00:00:00 -24:00:00
  212. drop table t1, test;
  213. select addtime("-01:01:01.01", "-23:59:59.1") as a;
  214. a
  215. -25:01:00.110000
  216. select microsecond("1997-12-31 23:59:59.01") as a;
  217. a
  218. 10000
  219. select microsecond(19971231235959.01) as a;
  220. a
  221. 10000
  222. select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
  223. a
  224. 1997-12-31 00:00:10.090000
  225. select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
  226. str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f")
  227. 2003-01-02 10:11:12.001200