- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:15 PM
I want to create a SQL statement that uses two different datetime fields to pull delta records. I know there is a field called "Use last run datetime", but it can only use one field, and only imports records where the datetime field is between the last import and the lastest datetime in the chosen column. It would be something like this pseudo code:
IMPORT id
FROM my_table
WHERE (
(created_dt BETWEEN {ts gs.now()} AND {ts gs.now()})
OR
(approved_dt BETWEEN {ts gs.now()} AND {ts gs.now()})
)
the challenge is how to add a function like gs.now() inside the query that runs daily.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 03:45 PM
I think the following documentation should be helpful:
https://docs.teradata.com/reader/kmuOwjp1zEYg98JsB8fu_A/W2ZJsPFeR7EFlyBUnQWrEw
https://teradata.github.io/presto/docs/0.167-t/functions/datetime.html
I haven't worked on Teradata SQL, but from looking at the documentation my guess would be:
SELECT *
FROM my_table
WHERE created > current_date - interval '2' day OR approved = current_date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 09:15 AM
Thanks for all the suggestions, specially to Manish. Even though this answer is outside what I was originally asked for, it is what I needed for my current use case.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 03:23 PM
Glad that it helped 🙂
Cheers,
Manish