Teradata 时间函数
2015-10-26 13:20
190 查看
时间差异(月):select (date '2003-08-15' - date '2003-01-01') month;
时间差异(天):select date '2003-08-15' - date '2003-01-01';[@more@]时间差异(秒):select
((time02 / 10000) * 3600 + (time02 / 100 MOD 100) * 60 + (time02 MOD 100)) -
((time01 / 10000) * 3600 + (time01 / 100 MOD 100) * 60 + (time01 MOD 100)) as time_diff
月份操作:select add_months(current_date, 3);
ADD_MONTHS(Date, -2)
add_months(date '2002-01-31', 1);
本月第一天:select date - extract(day from date) + 1
上月最后一天:select date '2008-03-03' - extract(day from '2008-03-03')
decemal转成time:select cast(cast(cast(TimeFld as format '99:99:99.99') as char(11)) as time(6)) from DBC.EventLog
依照当前时间得到timestamp: select cast(current_date as timestamp(2)) + ((current_time - time '00:00:00') hour to second);
上个星期五:select * from sys_calendar.calendar
where day_of_week = 6 --星期五
and calendar_date between date -6 and date; --上个星期
上周的今天:select * from sys_calendar.calendar where calendar_date = date-7
时间差异(天):select date '2003-08-15' - date '2003-01-01';[@more@]时间差异(秒):select
((time02 / 10000) * 3600 + (time02 / 100 MOD 100) * 60 + (time02 MOD 100)) -
((time01 / 10000) * 3600 + (time01 / 100 MOD 100) * 60 + (time01 MOD 100)) as time_diff
月份操作:select add_months(current_date, 3);
ADD_MONTHS(Date, -2)
add_months(date '2002-01-31', 1);
本月第一天:select date - extract(day from date) + 1
上月最后一天:select date '2008-03-03' - extract(day from '2008-03-03')
decemal转成time:select cast(cast(cast(TimeFld as format '99:99:99.99') as char(11)) as time(6)) from DBC.EventLog
依照当前时间得到timestamp: select cast(current_date as timestamp(2)) + ((current_time - time '00:00:00') hour to second);
上个星期五:select * from sys_calendar.calendar
where day_of_week = 6 --星期五
and calendar_date between date -6 and date; --上个星期
上周的今天:select * from sys_calendar.calendar where calendar_date = date-7
相关文章推荐
- socket网络编程复习笔记(一):套接字基本原理(上)
- java android面试题分析总结《三
- ssoj2453复制&粘贴(字符串)
- java android面试题分析总结《二》
- UIImagePickerController从本地相册加载图片
- 用Java访问带有Kerberos认证的HBase
- 看张子阳如何在30岁前年薪超过30万觉得很有道理几点
- Hibernate提示 Could not parse mapping document from resource...
- redis 学习指南
- 二分法查找(折半查找)
- PHP框架开发第一步——工厂模式
- android布局的问题----有些布局始终置底
- 雕虫小技---如何清空剪切板
- java android面试题分析总结《一》
- NSTimer
- 上海酒店分布数据接口分享
- Android 使用Websocket
- mapreduce运行的5个阶段
- UIPageControl
- Codeforces Round #327 (Div. 2) E. Three States BFS