在DB2中使用过的一些日期函数
查询时间字段(table_time_field)在本周的一些记录:
select * from tableName where WEEK(table_time_field) = WEEK(current date) ;
查询时间字段(table_time_field)在本月的一些记录:
select * from tableName where month(table_time_field) = month(current date) ;
查询时间字段(table_time_field)在昨天的一些记录:
select * from tableName where date(table_time_field) = (current date - 1 day) ;
查询时间字段(table_time_field)在上个月的一些记录:
select * from tableName where date(table_time_field) = (current date - 1 month) ;
更新timestamp字段:
update tableName set myTime=timestamp('2009-06-12 16:46:00');
本文介绍了如何在DB2数据库中使用日期函数进行数据查询与更新。包括查询本周、本月、昨天及上个月的数据记录,以及如何更新时间戳字段。
3558

被折叠的 条评论
为什么被折叠?



