date variable manipulation I'm working on DB2 stored procedure, which will be called by the Korn Shell (.ksh). My DB2 version is 11.5 and it is running on AIX.

I was stuck in TIMESTAMP to DATE conversion. Below is my requirement. 

If s_day &lt; day(s_date) then
start_date = YYYY-MM from s_date + 1 day from s_day 
end if


Note here s_date is DATE variable, s_day is CHAR variable and start_date is DATE variable.

So I tried, the following code, but got an error.

   IF s_day &lt; DAY(s_date) 
    THEN
    SET start_date = DATE (DATE(s_date,'YYYY-MM') || s_day + 1);
    END IF


Sample values

s_day =03
s_date= 15/05/2020
expected output start_date is 2020-05-04


Can anyone help me to achieve expected output?
Try 

IF int(s_day) &lt; DAY(s_date) 
THEN
    SET start_date = THIS_MONTH(s_date) + int(s_day) days;
END IF