【问题标题】:SQL get CreatedDate = 2 days agoSQL 获取 CreatedDate = 2 天前
【发布时间】:2022-01-22 01:23:24
【问题描述】:

我正在尝试通过 SFMC 实现以下目标。 我想从数据扩展中过滤记录,以使用两天前创建的每条记录填充新的数据扩展(与当天的时间无关)。

CreatedDate是需要过滤的字段,日期格式为:MM/DD/YYY HH:MM:SS AM

伪代码为:

Select *
From ent.Lead
Where CreatedDate = 2 days ago

正确的代码应该是什么样子的?

【问题讨论】:

  • 它是什么数据库?在 DB2 中类似于: Select * From ent.Lead Where date(CreatedDate) = current_date - 2 DAYS

标签: sql automation salesforce


【解决方案1】:

取决于您使用的数据库,但试试这个。

Select *
From ent.Lead
Where CreatedDate = sysdate - 2;

【讨论】:

    【解决方案2】:

    当然取决于数据库类型,但 PostgreSQL 看起来像:

    Select *
    From ent.Lead
    Where CreatedDate between dateadd ('days', -2, to_date(current_date)) and current_date
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-13
      • 1970-01-01
      • 1970-01-01
      • 2021-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多