Sample Header Ad - 728x90

Add days to date (char column with decimal) in DB2

0 votes
2 answers
1959 views
I have a table named INVOICE_ET which has column of below definition
INVDATE CHARACTER 10
result of select INVDATE from INVOICE_ET is as below
INVDATE
2021-07-31
In another table INVOICE_DY, I have a column named INV_DAYS, which has below definition
INV_DAYS  DECIMAL 3
result of select INV_DAYS from INVOICE_DY is as below
INV_DAYS 
88
----- Now my question is, I am trying to add INVOICE_DY.INV_DAYS field with INVOICE_ET.INVDATE field, but the char casting is not working, Please suggest how can I add these two columns. I am trying to get something like below
Select a.INVDATE, b.INV_DAYS, (a.INVDATE + b.INV_DAYS) as DUE_DATE 
from INVOICE_ET a 
join INVOICE_DY b 
On a.INVNUM = b.INVNUM //(edited this portion, because join is based on Invoice numbers)
Result should be 
INVDATE       INV_DAYS       DUE_DATE 
2021-07-31    88             2021-10-27
Any suggestions/ thoughts are welcome.
Asked by mrsorrted (21 rep)
Oct 12, 2021, 10:02 AM
Last activity: Oct 14, 2021, 09:24 AM