| toDayOfWeek() | 取日期或时间日期的星期(星期一为1,星期日为7)。 | toDayOfWeek(toDateTime(‘2018-12-11 11:12:13’)) toDayOfWeek(toDate(‘2018-12-11’)) | 返回 2返回 2 |
| toHour() | 取时间日期的小时 | toHour(toDateTime(‘2018-12-11 11:12:13’)) | 返回 11 |
| toMinute() | 取时间日期的分钟 | toMinute(toDateTime(‘2018-12-11 11:12:13’)) | 返回 12 |
| toSecond() | 取时间日期的秒 | toSecond(toDateTime(‘2018-12-11 11:12:13’)) | 返回 13 |
| toMonday() | 取时间日期最近的周一(返回日期) | toMonday(toDate(‘2018-12-11’)) toMonday(toDateTime(‘2018-12-11 11:12:13’)) | 返回 2018-12-10返回 2018-12-10 |
| toTime() | 将时间日期的日期固定到某一天,保留原始时间 | toTime(toDateTime(‘2018-12-11 11:12:13’)) | 返回 1970-01-02 11:12:13 |
1.2 时间或日期截取函数(toStartOf)—— 返回日期
函数 | 用途 | 举例 | 结果 |
toStartOfMonth() | 取日期或时间日期的月份的第一天,返回日期 | toStartOfMonth(toDateTime(‘2018-12-11 11:12:13’))toStartOfMonth(toDate(‘2018-12-11’)) | 返回 2018-12-01返回 2018-12-01 |
toStartOfQuarter() | 取日期或时间日期的季度的第一天,返回日期 | toStartOfQuarter(toDateTime(‘2018-12-11 11:12:13’))toStartOfQuarter(toDate(‘2018-12-11’)) | 返回 2018-10-01返回 2018-10-01 |
toStartOfYear() | 取日期或时间日期的年份的第一天,返回日期 | toStartOfYear(toDateTime(‘2018-12-11 11:12:13’))toStartOfYear(toDate(‘2018-12-11’)) | 返回 2018-01-01返回 2018-01-01 |
toStartOfMinute() | 截取时间日期到分钟(之后归零),返回日期 | toStartOfMinute(toDateTime(‘2018-12-11 11:12:13’)) | 返回 2018-12-11 11:12:00 |
toStartOfFiveMinute() | 截取时间日期到最近的5的倍数分钟(之后归零),返回日期 | toStartOfFiveMinute(toDateTime(‘2018-12-11 11:12:13’)) | 返回 2018-12-11 11:10:00 |
toStartOfFifteenMinutes() | 截取时间日期到最近的15的倍数分钟(之后归零),返回日期 | toStartOfFifteenMinutes(toDateTime(‘2018-12-11 11:12:13’)) | 返回 2018-12-11 11:00:00 |
toStartOfHour() | 截取时间日期到小时(之后归零),返回日期 | toStartOfHour(toDateTime(‘2018-12-11 11:12:13’)) | 返回 2018-12-11 11:00:00 |
toStartOfDay() | 截取时间日期到天(之后归零),返回日期 | toStartOfDay(toDateTime(‘2018-12-11 11:12:13’)) | 返回 2018-12-11 00:00:00 |
timeSlot() | 将时间日期中,分钟大于等于30的归于30,分钟数小于30的归为00 | timeSlot(toDateTime(‘2018-12-11 11:33:13’))timeSlot(toDateTime(‘2018-12-11 11:33:13’)) | 返回 2018-12-11 11:00:00返回 2018-12-11 11:30:00 |