目录
1.3 时间或日期截取函数(toStartOf)—— 返回日期
1.日期类函数
1.1 日期或时间日期生成函数
函数 |
用途 |
举例 |
返回结果 |
返回类型 |
now() |
生成当前时间日期 |
now() |
2020-08-14 23:46:34 |
DateTime |
today() |
生成今天的日期 |
today() |
2020-08-14 |
Date |
yesterday() |
生成昨天的日期 |
yesterday() |
2020-08-13 |
Date |
1.2 时间或日期截取函数(to)-返回非日期
函数 |
用途 |
举例 |
返回结果 |
返回类型 |
toYear() |
取日期或时间日期的年份 |
toYear(toDateTime('2020-08-14 11:12:13’)); toYear(toDate('2020-08-14’)); toYear(now()); |
2020; 2020; 2020; |
UInt16; UInt16; UInt16 |
toMonth() |
取日期或时间日期的月份 |
toMonth(toDateTime('2020-08-13 11:12:13’)); toMonth(toDate('2020-08-13')) |
8; 8; |
UInt8; UInt8 |
toDayOfMonth() |
取日期或时间日期的天(1-31) |
toDayOfMonth(now()) |
14 |
UInt8 |
toDayOfWeek() |
取日期或时间日期的星期 |
toDayOfWeek(now()); |
6 |
UInt8 |
toHour() |
取时间日期的小时 |
toHour(toDateTime('2020-08-13 11:12:13')) |
11 |
UInt8 |
toMinute() |
取时间日期的分钟 |
toMinute(toDateTime(‘2020-08-13 11:12:13’)) |
12 |
UInt8 |
toSecond() |
取时间日期的秒 |
toSecond(toDateTime(‘2020-08-13 11:12:13’)) |
13 |
UInt8 |
toMonday() |
取时间日期最近的周一(返回日期) |
toMonday(toDate('2020-08-13')); |
2020-08-10 |
Date |
toTime() |
将时间日期的日期固定到某一天,保留原始时间 |
toTime(toDateTime(‘2020-08-13 11:12:13’)) |
1970-01-02 11:12:13 |
DateTime('Asia/Chungking') |
1.3 时间或日期截取函数(toStartOf)—— 返回日期
函数 |
用途 |
举例 |
返回结果 |
返回类型 |
toStartOfMonth() |
取日期或时间日期的月份的第一天,返回日期。 |
toStartOfMonth(toDateTime('2020-08-18 11:12:13')) |
2020-08-01 |
Date |
toStartOfQuarter() |
取日期或时间日期的季度的第一天,返回日期 |
toStartOfQuarter(toDateTime('2018-12-11 11:12:13')) |
2018-10-01 |
Date |
toStartOfYear() |
取日期或时间日期的年份的第一天,返回日期 |
toStartOfYear(toDateTime('2020-08-18 11:12:13')); toStartOfYear(toDate('2020-08-18')) |
2020-01-01; 2020-01-01 |
Date; Date |
toStartOfMinute() |
截取时间日期到分钟(之后归零),返回日期 |
toStartOfMinute(toDateTime('2020-08-18 11:12:13')) |
2020-08-18 11:12:00 |
DateTime('Asia/Chungking') |
toStartOfFiveMinute() |
截取时间日期到最近的5的倍数分钟(之后归零),返回日期 |
toStartOfFiveMinute(toDateTime('2020-08-18 11:12:13')) |
2020-08-18 11:10:00 |
DateTime('Asia/Chungking') |
toStartOfFifteenMinutes |
截取时间日期到最近的15的倍数分钟(之后归零),返回日期 |
toStartOfFifteenMinutes(toDateTime('2020-08-18 11:12:13')) |
2020-08-18 11:00:00 |
DateTime('Asia/Chungking') |
toStartOfHour() |
截取时间日期到小时(之后归零),返回日期 |
toStartOfHour(toDateTime('2020-08-18 11:12:13') |
2020-08-18 11:00:00 |
DateTime('Asia/Chungking') |
toStartOfDay() |
截取时间日期到天(之后归零),返回日期 |
toStartOfDay(toDateTime('2020-08-18 11:12:13')) |
2020-08-18 00:00:00 |
DateTime('Asia/Chungking') |
timeSlot() |
将时间日期中,分钟大于等于30的归于30,分钟数小于30的归为00 |
timeSlot(toDateTime('2020-08-18 11:33:13’)) |
2020-08-18 11:30:00; |
DateTime('Asia/Chungking') |