【问题标题】:Time date calculations for different months in TeradataTeradata 中不同月份的时间日期计算
【发布时间】:2014-10-20 00:42:50
【问题描述】:

如何在 Teradata 中计算以下内容:

Beginning Of Previous Month, 
End Of Previous Month, 
Beginning Of Six Months Ago, 
Beginning Of Twelve Months Ago

谢谢。

【问题讨论】:

    标签: date time teradata


    【解决方案1】:
    Beginning Of Previous Month:    add_months(current_date - (extract(day from current_date)-1), -1) 
    End Of Previous Month:                     current_date - (extract(day from current_date))
    Beginning Of Six Months Ago:    add_months(current_date - (extract(day from current_date)-1), -6) 
    Beginning Of Twelve Months Ago: add_months(current_date - (extract(day from current_date)-1), -12) 
    

    根据您的版本,可能会有一些功能:

    td_month_begin(add_months(current_date,-1))
    last_day(add_months(current_date,-1))
    

    或者你检查你(希望)现有的日历表,如果这些列已经存在。

    【讨论】:

    • 非常感谢上述陈述对我来说非常有效。
    猜你喜欢
    • 2014-04-26
    • 2021-05-17
    • 1970-01-01
    • 2020-09-27
    • 2022-11-18
    • 1970-01-01
    • 1970-01-01
    • 2017-12-24
    • 2019-12-27
    相关资源
    最近更新 更多