I have a simple query to pull DAYOFWEEK from SYSIBM/SYSDUMMY1 to determine whether or not to clear a table that tracks yesterday sales.
DELETE FROM DAILYSALES WHERE (CASE WHEN (SELECT DAYOFWEEK(CURRENT DATE)
FROM SYSIBM/SYSDUMMY1)
BETWEEN 3 AND 6 THEN 'YES' ELSE 'NO' END) = 'YES';
Since the report that runs on Monday (dayofweek=2) needs Friday (dayofweek=6), Saturday (dayofweek=7), Sunday (dayofweek=1) sales (today-1 to calculate date), it would seem logical that I should see sales figures for days 6, 7, and 1.
However, it seems to be retaining Thursday's (dayofweek=5) sales and not pulling Sunday sales (dayofweek=1) when it runs on Monday morning. This leads me to believe the date being used by SYSDUMMY1 doesn't flip until long after midnight, even though our system date flips at midnight EST.
It runs fine the rest of the week, providing the correct sales data for 'yesterday'. When I manually run Select DAYOFWEEK(current date) from SYSIBM.SYSDUMMY1, it always shows the correct dayofweek. What am I missing?