1 Working Day Back In SQL DB2

I need to select data from database with a date that is one day back into the past but on working day. Is there a specific function for that ( Excel has got formula =Workday)?

I am downloading data from DB2 to excel with VBA instructions.

Here is the piece of code I use for calendar day.

strSQL = "SELECT *" strSQL = strSQL & " FROM PDB2I.DI_HIS_EXH_RAT_01" strSQL = strSQL & " WHERE CAR_DT = CURRENT DATE - 1 DAY"

Thanks in advance for any directions

-------------Problems Reply------------

select *
from mytable
where mydate = current date -
(case when dayofweek(current date) = 1 then 2 -- sonntag
when dayofweek(current date) = 2 then 3 -- montag
else 1 end) days

Check what day of the week it is and change accordingly

select * from table_x where timestamp_x > (select PREV_WEEKDAY from(select sysdate as current_date,
case when to_char(sysdate,'D') in (1,2,7)
then next_day(sysdate-7,'Friday')
else sysdate-1 end as prev_weekday
from dual))

Category:sql Views:2 Time:2018-10-30
Tags: sql db2 vba

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.135 (s). 11 q(s)