南大通用GBase 8a日期函数date_part和extract的介绍和使用样例

GBase 8a提供了date_part来提取日期的部分属性,同时提供了与oracle兼容的extract函数。本文介绍这2个函数的使用方法。

参考

GBase 8a日期截断函数date_trunc使用样例

语法

date_part(type,date)
extract(type from date)
  • type 提取的位置。其中milliseconds返回结果为decimal,其它的为bigint(12)
  • date 日期,一般是datetime类型。如果是date类型会自动转成datetime

其中type类型,date_part同时支持不带引号和带引号两种写法,比如 year和'year'。

注意epoch在date_part不支持,仅extract支持。

Type类型说明date_part/extractdate_trunc
year日期中的年的部分。请注意区分isoyear。年以下的设置为01-01 00:00:00
year_month年月返回年和月不支持
quarter季度返回属于第几个季度。
1:01-01 - 03-31
2:04-01 - 06-30
3:07-01 - 09-30
4:10-01 - 12-31
日期所在季度的第一天,时间部分为00:00:00
month日期中的月份日期所在月的第一天,时间部分为00:00:00
week日期所在当年的第几周日期所在周的周一,时间部分为00:00:00
day日期中的日日期的时间部分设置为00:00:00
day_hour日,小时日期中的日和小时不支持
day_minute日、小时、分日期中的日、小时和分不支持
day_second日、小时、分、秒日期中的日、小时、分和秒不支持
hour小时日期中的小时部分小时以下设置为00:00
hour_minute小时、分钟日期中的小时、分钟部分不支持
hour_second小时、分、秒日期中的小时、分种、表部分不支持
minute分钟日期中的分钟部分分钟以下的设置为0
minute_second分钟、秒日期中的分、秒部分不支持
second日期中的秒秒以下设置为0
millisecond毫秒日期中的毫秒部分不支持
microsecond微秒日期中的微秒部分不支持
day_microsecond天、小时、分、秒、微秒日期中的天、小时、分、秒、微秒部分。
注意格式为ddhhmmssXXXXXX
不支持
hour_microsecond小时、分、秒、微秒日期中的小时、分、秒、微秒部分。
注意格式为hhmmssXXXXXX
不支持
minute_microsecond分、秒、微秒日期中的分、秒、微秒部分。
注意格式为mmssXXXXXX
不支持
second_microsecond秒、微秒日期中的秒、微秒部分。
注意格式为ssXXXXXX
不支持
Century世纪该日期所在的世纪。以百年为单位,整百年为上一世纪。
0001-0100 第1世纪
0101-2000 第2世纪
...
2021-2100 第21世纪
该日期所在世纪的第一天
decade十年年份的10取整。比如2023年算202个10年。日期所在10年的第一天。时间为0
dow周的第几天0-6日期是所在周的第几天。周日为0,周一为1,周六为6
注意和isodow的区别
不支持
doy年的第几天日期是当前的第几天不支持
epoch带微秒的时间戳extract支持,与unix_timestamp类似,多了微秒部分(如果有的话)
1682046733.56789
不支持
isodow周的第几天1-7日期是所在周的第几天。周一为1,周六为6,周日为7
注意和dow的区别
不支持
isoyear日期落在iso8601周编号的年按照iso8601编号,每年第一个周四所在的周作为该年的第一周。买年最后一个周四所在的周作为该年的最后一周。所以年初,年末的日期,可能是上一年或者下一年的。
注意和year的区别。
不支持
millennium千年当前年份是第几个千年
0001-1000 为第1个千年
1001-2000 为第2个千年
2001-3000 为第3个千年 ...
日期所在千年的第一天。
milliseconds秒,毫秒返回时间中的秒和毫秒部分毫秒以下设置为0
microseconds秒,微秒
等同于second_microsecond
返回秒,微秒部分。
注意格式为ssXXXXXX
微秒以下设置为0

year

返回日期年的部分。

参数是否有双引号均可,后面的例子不再重复。

gbase> select date_part(year,'2023-04-23 11:12:13.56789');
+---------------------------------------------+
| date_part(year,'2023-04-23 11:12:13.56789') |
+---------------------------------------------+
|                                        2023 |
+---------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select date_part('year','2023-04-23 11:12:13.56789');
+-----------------------------------------------+
| date_part('year','2023-04-23 11:12:13.56789') |
+-----------------------------------------------+
|                                          2023 |
+-----------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(year from '2023-04-23 11:12:13.56789');
+------------------------------------------------+
| extract(year from '2023-04-23 11:12:13.56789') |
+------------------------------------------------+
|                                           2023 |
+------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

year_month

日期的年月部分。

gbase> select date_part(year_month,'2023-04-23 11:12:13.56789');
+---------------------------------------------------+
| date_part(year_month,'2023-04-23 11:12:13.56789') |
+---------------------------------------------------+
|                                            202304 |
+---------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(year_month from '2023-04-23 11:12:13.56789');
+------------------------------------------------------+
| extract(year_month from '2023-04-23 11:12:13.56789') |
+------------------------------------------------------+
|                                               202304 |
+------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

quarter

日期所在季度

gbase> select date_part(quarter,'2023-04-23 11:12:13.56789');
+------------------------------------------------+
| date_part(quarter,'2023-04-23 11:12:13.56789') |
+------------------------------------------------+
|                                              2 |
+------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(quarter from '2023-04-23 11:12:13.56789');
+---------------------------------------------------+
| extract(quarter from '2023-04-23 11:12:13.56789') |
+---------------------------------------------------+
|                                                 2 |
+---------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

month

日期所在月份

gbase> select date_part(month,'2023-04-23 11:12:13.56789');
+----------------------------------------------+
| date_part(month,'2023-04-23 11:12:13.56789') |
+----------------------------------------------+
|                                            4 |
+----------------------------------------------+
1 row in set (Elapsed: 00:00:00.01)

gbase> select extract(month from '2023-04-23 11:12:13.56789');
+-------------------------------------------------+
| extract(month from '2023-04-23 11:12:13.56789') |
+-------------------------------------------------+
|                                               4 |
+-------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

week

日期所在周,与week(XXX)返回一致。 根据模式不同,每年的前几天,可能是第0周或第1周。

参考
GBase 8a的week函数模式实现每年的第1天总是第1周,哪怕就1天也算
GBase 8a数据库配置参数default_week_format设置星期的模式

gbase> select date_part(week,'2023-04-23 11:12:13.56789');
+---------------------------------------------+
| date_part(week,'2023-04-23 11:12:13.56789') |
+---------------------------------------------+
|                                          17 |
+---------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(week from '2023-04-23 11:12:13.56789');
+------------------------------------------------+
| extract(week from '2023-04-23 11:12:13.56789') |
+------------------------------------------------+
|                                             17 |
+------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

day

日期中的的天。

gbase> select date_part(day,'2023-04-23 11:12:13.56789');
+--------------------------------------------+
| date_part(day,'2023-04-23 11:12:13.56789') |
+--------------------------------------------+
|                                         23 |
+--------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(day from '2023-04-23 11:12:13.56789');
+-----------------------------------------------+
| extract(day from '2023-04-23 11:12:13.56789') |
+-----------------------------------------------+
|                                            23 |
+-----------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

day_hour

日期中的天和小时

gbase> select date_part(day_hour,'2023-04-23 11:12:13.56789');
+-------------------------------------------------+
| date_part(day_hour,'2023-04-23 11:12:13.56789') |
+-------------------------------------------------+
|                                            2311 |
+-------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(day_hour from '2023-04-23 11:12:13.56789');
+----------------------------------------------------+
| extract(day_hour from '2023-04-23 11:12:13.56789') |
+----------------------------------------------------+
|                                               2311 |
+----------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

day_minute

日期中的天、小时和分钟。

gbase> select date_part(day_minute,'2023-04-23 11:12:13.56789');
+---------------------------------------------------+
| date_part(day_minute,'2023-04-23 11:12:13.56789') |
+---------------------------------------------------+
|                                            231112 |
+---------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(day_minute from '2023-04-23 11:12:13.56789');
+------------------------------------------------------+
| extract(day_minute from '2023-04-23 11:12:13.56789') |
+------------------------------------------------------+
|                                               231112 |
+------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

day_second

日期中的天、小时、分钟和秒。

gbase> select date_part(day_second,'2023-04-23 11:12:13.56789');
+---------------------------------------------------+
| date_part(day_second,'2023-04-23 11:12:13.56789') |
+---------------------------------------------------+
|                                          23111213 |
+---------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(day_second from '2023-04-23 11:12:13.56789');
+------------------------------------------------------+
| extract(day_second from '2023-04-23 11:12:13.56789') |
+------------------------------------------------------+
|                                             23111213 |
+------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

hour

日期中的小时

gbase> select date_part(hour,'2023-04-23 11:12:13.56789');
+---------------------------------------------+
| date_part(hour,'2023-04-23 11:12:13.56789') |
+---------------------------------------------+
|                                          11 |
+---------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(hour from '2023-04-23 11:12:13.56789');
+------------------------------------------------+
| extract(hour from '2023-04-23 11:12:13.56789') |
+------------------------------------------------+
|                                             11 |
+------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

hour_minute

日期中的小时和分钟。

gbase> select date_part(hour_minute,'2023-04-23 11:12:13.56789');
+----------------------------------------------------+
| date_part(hour_minute,'2023-04-23 11:12:13.56789') |
+----------------------------------------------------+
|                                               1112 |
+----------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(hour_minute from '2023-04-23 11:12:13.56789');
+-------------------------------------------------------+
| extract(hour_minute from '2023-04-23 11:12:13.56789') |
+-------------------------------------------------------+
|                                                  1112 |
+-------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

hour_second

日期中的小时、分钟和秒。

gbase> select date_part(hour_second,'2023-04-23 11:12:13.56789');
+----------------------------------------------------+
| date_part(hour_second,'2023-04-23 11:12:13.56789') |
+----------------------------------------------------+
|                                             111213 |
+----------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(hour_second from '2023-04-23 11:12:13.56789');
+-------------------------------------------------------+
| extract(hour_second from '2023-04-23 11:12:13.56789') |
+-------------------------------------------------------+
|                                                111213 |
+-------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

minute

日期中的分钟

gbase> select date_part(minute,'2023-04-23 11:12:13.56789');
+-----------------------------------------------+
| date_part(minute,'2023-04-23 11:12:13.56789') |
+-----------------------------------------------+
|                                            12 |
+-----------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(minute from '2023-04-23 11:12:13.56789');
+--------------------------------------------------+
| extract(minute from '2023-04-23 11:12:13.56789') |
+--------------------------------------------------+
|                                               12 |
+--------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

minute_second

日期中的分钟和秒

gbase> select date_part(minute_second,'2023-04-23 11:12:13.56789');
+------------------------------------------------------+
| date_part(minute_second,'2023-04-23 11:12:13.56789') |
+------------------------------------------------------+
|                                                 1213 |
+------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(minute_second from '2023-04-23 11:12:13.56789');
+---------------------------------------------------------+
| extract(minute_second from '2023-04-23 11:12:13.56789') |
+---------------------------------------------------------+
|                                                    1213 |
+---------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

second

日期中的秒

gbase> select date_part(second,'2023-04-23 11:12:13.56789');
+-----------------------------------------------+
| date_part(second,'2023-04-23 11:12:13.56789') |
+-----------------------------------------------+
|                                            13 |
+-----------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(second from '2023-04-23 11:12:13.56789');
+--------------------------------------------------+
| extract(second from '2023-04-23 11:12:13.56789') |
+--------------------------------------------------+
|                                               13 |
+--------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

millisecond

日期中的毫秒。也就是秒以下6位微秒数字除以1000截断取整,没有四舍五入。

注意小数点后如果不足6位,要按在末尾补0的情况考虑。 0.1 和 0.100000对应。

gbase> select date_part(millisecond,'2023-04-23 11:12:13.56789');
+----------------------------------------------------+
| date_part(millisecond,'2023-04-23 11:12:13.56789') |
+----------------------------------------------------+
|                                                567 |
+----------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(millisecond from '2023-04-23 11:12:13.56789');
+-------------------------------------------------------+
| extract(millisecond from '2023-04-23 11:12:13.56789') |
+-------------------------------------------------------+
|                                                   567 |
+-------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

microsecond

日期中的微秒部分。注意当前返回值为6位数的微秒。如果想忽略掉超过1000部分,需要%1000。

gbase> select date_part(microsecond,'2023-04-23 11:12:13.56789');
+----------------------------------------------------+
| date_part(microsecond,'2023-04-23 11:12:13.56789') |
+----------------------------------------------------+
|                                             567890 |
+----------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(microsecond from '2023-04-23 11:12:13.56789');
+-------------------------------------------------------+
| extract(microsecond from '2023-04-23 11:12:13.56789') |
+-------------------------------------------------------+
|                                                567890 |
+-------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

day_microsecond

日期中的天、小时、分钟、秒和微秒。微秒不足6位的,最后补0。

gbase> select date_part(day_microsecond,'2023-04-23 11:12:13.56789');
+--------------------------------------------------------+
| date_part(day_microsecond,'2023-04-23 11:12:13.56789') |
+--------------------------------------------------------+
|                                         23111213567890 |
+--------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(day_microsecond from '2023-04-23 11:12:13.56789');
+-----------------------------------------------------------+
| extract(day_microsecond from '2023-04-23 11:12:13.56789') |
+-----------------------------------------------------------+
|                                            23111213567890 |
+-----------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

hour_microsecond

日期中的小时、分钟、秒和微秒。微秒不足6位的,最后补0。

gbase> select date_part(hour_microsecond,'2023-04-23 11:12:13.56789');
+---------------------------------------------------------+
| date_part(hour_microsecond,'2023-04-23 11:12:13.56789') |
+---------------------------------------------------------+
|                                            111213567890 |
+---------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(hour_microsecond from '2023-04-23 11:12:13.56789');
+------------------------------------------------------------+
| extract(hour_microsecond from '2023-04-23 11:12:13.56789') |
+------------------------------------------------------------+
|                                               111213567890 |
+------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

minute_microsecond

日期中的分钟、秒和微秒部分。微秒不足6位的,最后补0。

gbase> select date_part(minute_microsecond,'2023-04-23 11:12:13.56789');
+-----------------------------------------------------------+
| date_part(minute_microsecond,'2023-04-23 11:12:13.56789') |
+-----------------------------------------------------------+
|                                                1213567890 |
+-----------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(minute_microsecond from '2023-04-23 11:12:13.56789');
+--------------------------------------------------------------+
| extract(minute_microsecond from '2023-04-23 11:12:13.56789') |
+--------------------------------------------------------------+
|                                                   1213567890 |
+--------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

second_microsecond

日期中的秒和微秒部分。微秒不足6位的,最后补0。

gbase> select date_part(second_microsecond,'2023-04-23 11:12:13.56789');
+-----------------------------------------------------------+
| date_part(second_microsecond,'2023-04-23 11:12:13.56789') |
+-----------------------------------------------------------+
|                                                  13567890 |
+-----------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(second_microsecond from '2023-04-23 11:12:13.56789');
+--------------------------------------------------------------+
| extract(second_microsecond from '2023-04-23 11:12:13.56789') |
+--------------------------------------------------------------+
|                                                     13567890 |
+--------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

century

该日期所在世纪。

gbase> select date_part(century,'2023-04-23 11:12:13.56789');
+------------------------------------------------+
| date_part(century,'2023-04-23 11:12:13.56789') |
+------------------------------------------------+
|                                             21 |
+------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(century from '2023-04-23 11:12:13.56789');
+---------------------------------------------------+
| extract(century from '2023-04-23 11:12:13.56789') |
+---------------------------------------------------+
|                                                21 |
+---------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

decade

日期所在10年

gbase> select date_part(decade,'2023-04-23 11:12:13.56789');
+-----------------------------------------------+
| date_part(decade,'2023-04-23 11:12:13.56789') |
+-----------------------------------------------+
|                                           202 |
+-----------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(decade from '2023-04-23 11:12:13.56789');
+--------------------------------------------------+
| extract(decade from '2023-04-23 11:12:13.56789') |
+--------------------------------------------------+
|                                              202 |
+--------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

dow

Day of Week 该日期为所在日期的第几天。周日为0,周六为6。请区分isodow。

gbase> select date_part(dow,'2023-04-23 11:12:13.56789');
+--------------------------------------------+
| date_part(dow,'2023-04-23 11:12:13.56789') |
+--------------------------------------------+
|                                          0 |
+--------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(dow from '2023-04-23 11:12:13.56789');
+-----------------------------------------------+
| extract(dow from '2023-04-23 11:12:13.56789') |
+-----------------------------------------------+
|                                             0 |
+-----------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

doy

day of year 该日期为所在年的第几天。

gbase> select date_part(doy,'2023-04-23 11:12:13.56789');
+--------------------------------------------+
| date_part(doy,'2023-04-23 11:12:13.56789') |
+--------------------------------------------+
|                                        113 |
+--------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(doy from '2023-04-23 11:12:13.56789');
+-----------------------------------------------+
| extract(doy from '2023-04-23 11:12:13.56789') |
+-----------------------------------------------+
|                                           113 |
+-----------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

epoch

该日期带微秒的时间戳。与unix_timestamp类似。

date_part暂时不支持。

gbase> select date_part(epoch,'2023-04-23 11:12:13.56789');
ERROR 1733 (HY000): (GBA-01EX-700) Gbase general error: This version of GBase doesn't yet support 'EPOCH in date_part
gbase>
gbase> select extract(epoch from '2023-04-23 11:12:13.56789') a,unix_timestamp('2023-04-23 11:12:13.56789') b;
+------------------+------------+
| a                | b          |
+------------------+------------+
| 1682219533.56789 | 1682219533 |
+------------------+------------+
1 row in set (Elapsed: 00:00:00.00)

isodow

ISO8601 Day of Week 该日期为所在日期的第几天。周日为7,周一为1。请区分dow。

gbase> select date_part(isodow,'2023-04-23 11:12:13.56789');
+-----------------------------------------------+
| date_part(isodow,'2023-04-23 11:12:13.56789') |
+-----------------------------------------------+
|                                             7 |
+-----------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(isodow from '2023-04-23 11:12:13.56789');
+--------------------------------------------------+
| extract(isodow from '2023-04-23 11:12:13.56789') |
+--------------------------------------------------+
|                                                7 |
+--------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

isoyear

按照ISO8601 每年第一个周四周四所在的周为第一周,最后一个周四为最后一周。所以年初和年尾的日期日期可能属于上一年或者下一年。

gbase> select date_part(isoyear,'2023-01-01 11:12:13.56789') isoyear,date_part(year,'2023-01-01 11:12:13.56789') year;
+---------+------+
| isoyear | year |
+---------+------+
|    2022 | 2023 |
+---------+------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(isoyear from '2023-01-01 11:12:13.56789') isoyear,extract(year from '2023-01-01 11:12:13.56789') year;
+---------+------+
| isoyear | year |
+---------+------+
|    2022 | 2023 |
+---------+------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select date_part(isoyear,'2024-12-31 11:12:13.56789');
+------------------------------------------------+
| date_part(isoyear,'2024-12-31 11:12:13.56789') |
+------------------------------------------------+
|                                           2025 |
+------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

millennium

日期所在的第几个千年。

gbase> select date_part(millennium,'2023-04-23 11:12:13.56789');
+---------------------------------------------------+
| date_part(millennium,'2023-04-23 11:12:13.56789') |
+---------------------------------------------------+
|                                                 3 |
+---------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(millennium from '2023-04-23 11:12:13.56789');
+------------------------------------------------------+
| extract(millennium from '2023-04-23 11:12:13.56789') |
+------------------------------------------------------+
|                                                    3 |
+------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

milliseconds

日期的秒和毫秒部分,单位是毫秒

gbase> select date_part(milliseconds,'2023-04-23 11:12:13.56789');
+-----------------------------------------------------+
| date_part(milliseconds,'2023-04-23 11:12:13.56789') |
+-----------------------------------------------------+
|                                            13567.89 |
+-----------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)
gbase> select extract(milliseconds from '2023-04-23 11:12:13.56789');
+--------------------------------------------------------+
| extract(milliseconds from '2023-04-23 11:12:13.56789') |
+--------------------------------------------------------+
|                                               13567.89 |
+--------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

microseconds

日期中的秒到微秒部分,单位是微秒

gbase> select date_part(microseconds,'2023-04-23 11:12:13.56789');
+-----------------------------------------------------+
| date_part(microseconds,'2023-04-23 11:12:13.56789') |
+-----------------------------------------------------+
|                                            13567890 |
+-----------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select extract(microseconds from '2023-04-23 11:12:13.56789');
+--------------------------------------------------------+
| extract(microseconds from '2023-04-23 11:12:13.56789') |
+--------------------------------------------------------+
|                                               13567890 |
+--------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)