Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

1 Working Day Back In SQL DB2

Tags:

sql

vba

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

like image 485
Tommeck37 Avatar asked Mar 19 '26 22:03

Tommeck37


1 Answers

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
like image 96
Peter Miehle Avatar answered Mar 22 '26 16:03

Peter Miehle