微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SQLITE 日期偏移

如何解决SQLITE 日期偏移

我正在尝试复制以下内容,这些内容是用某种其他风格的 sql 编写的:

where contact_date <= open_date 
        and contact_date  >= dateadd(days,-30,open_date)

下面是我的 sqlITE 查询,我用 sqlITE 日期模拟替换了 dateadd,但没有按预期运行。我确保这些列是“DATE”类型,但是当我使用 date 函数进行 30 天偏移时,它只是将日期设为 NULL。

这是我现在的查询

SELECT Template,"Outcome Date" as contact_date,"Open Date" as open_date,date("Open Date",'-30 day') window_date_start
--cast("Outcome Date" as integer) contact_date_int,cast("Open Date" as integer) open_date_int,--strftime('%m/%d/%Y %H:%M',"Outcome Date") as contact_date_strft,strftime('%m/%d/%Y %H:%M',"Open Date") as open_date_strft 
from Emails e
join Listing l
on l."Onovative Id" = e."Onovative Id"
where
contact_date <= open_date
--and contact_date > date(open_date,'-30 day');   <=== Not working

输出

Template    contact_date    open_date   window_date_start   <=== cannot really see below,but NULL
product offer loans auto runoff email   5/20/2020 11:02 6/19/2020 0:00  
onboarding digital banking email    5/22/2020 11:02 6/24/2020 0:00  
onboarding digital banking email    5/22/2020 11:02 5/5/2020 0:00   
product offer loans auto runoff email   5/22/2020 11:02 6/25/2020 0:00  
onboarding deposits checking 100 email  5/29/2020 11:06 9/24/2020 0:00  
onboarding deposits checking 100 email  5/29/2020 11:06 5/5/2020 0:00   
onboarding digital banking email    5/29/2020 11:06 9/9/2020 0:00   
onboarding digital banking email    5/29/2020 11:06 6/9/2020 0:00   
product offer loans auto runoff email   5/29/2020 15:12 9/30/2020 0:00
...

有人知道如何在 sqlITE 中偏移日期吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。