简体   繁体   中英

SQL get CreatedDate = 2 days ago

I'm trying to achieve the following with SFMC. I want to filter records from a Data extension to populate a new data extension with every record that was created two days ago (irrespective of the time during that day).

The CreatedDate is the field that needs to be filtered and the date format is: MM/DD/YYY HH:MM:SS AM

The pseudo code is:

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

How should the right code look like?

Depends on the DB you are using, but try this.

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

Depends on the DB type for sure, but PostgreSQL it would look something like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM