在 Netezza 中为日期添加天数 [英] Adding days to a date in Netezza

查看:76
本文介绍了在 Netezza 中为日期添加天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询从字段 [DATE] BETWEEN '10/1/2017' AND '10/31/2017' 中提取日期

I have a query pulling dates from field [DATE] BETWEEN '10/1/2017' AND '10/31/2017'

我想在条件之间的结束日期中添加天数 (10/31/2017).似乎不可能.我可以使用 ADD_MONTHS 完美地添加月份,但似乎没有函数 ADD_DAYS.

I want to add days to the the end date in the between criteria (10/31/2017). It seems impossible. I can add months perfectly using ADD_MONTHS, but there doesn't seem to be a function ADD_DAYS.

非常感谢您的帮助!

推荐答案

add_months 处理因月份长度可变而产生的特殊情况.

add_months deals with the special cases that arise from having variable length months.

对于其他时间间隔,事情要简单得多:

For other intervals of time, things are much simpler:

要将 5 天添加到当天,请使用:

To add 5 days to the current day, use this:

SYSTEM.ADMIN(ADMIN)=> select current_date, current_date + interval '5 days';
    DATE    |      ?COLUMN?       
------------+---------------------
 2017-12-19 | 2017-12-24 00:00:00
(1 row)

T2DB.ADMIN(ADMIN)=> select * from interval_test where col1 between (current_timestamp - interval '2 days') and (current_timestamp + interval '3 days');
    COL1    
------------
 2017-12-19
(1 row)

这篇关于在 Netezza 中为日期添加天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆