supyo
supyo

Reputation: 3037

SQL - Test if data has been updated for today in DB2

I'm trying to test if a DB2 table has been updated today.

I can get the latest update date:

SELECT DATE(REFRESH_TIME) as rfrsh_day
FROM SYSIBM.SYSTABLES
WHERE NAME in ('my_table');

and today's date:

SELECT current date as today FROM SYSIBM.SYSDUMMY1;

I want a TRUE if rfrsh_day == today, otherwise FALSE. How would I compare these in a single SQL statement?

Upvotes: 0

Views: 108

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269873

Use a case statement:

SELECT (case when DATE(REFRESH_TIME) = CURRENT DATE then 'true' else 'false' end) as rfrsh_day
FROM SYSIBM.SYSTABLES
WHERE NAME in ('my_table');

Upvotes: 1

Related Questions