db2 luw - DB2 - Determine a future date based on two fields -
I need to calculate a date in DB2 for Unix.
I have a date field: CONTRACT_DT (example: 2/7/2006, 8/25/2006, 11/16/2007, 2/25/2008, 12/29/2005)
and one type of field head (example: C, I, E, Z, V, K)
I need to calculate the next date that the loan will be reviewed (REVIEW_DT ).
An example loan 01 has a CONTRACT_DT of 3/1/2004, and V PRIME. So I need to count 3/1 for three years / 2004, unless I have a date of more than MTHLY_CLOSE_DT. (Option 2007, 2010, 2013, 2016, 2019, 2022).
The correct answer is 3/1/2016.
I know that the structure is a matter statement, but I have no idea how to choose a date based on multiples of the year and there is one more than the MNTHEYCTTDTT.
Even what I have so far:
created process "finance" "AL_LOOP_TEST" (out R. RVDT Date) BEGIN Nuclear Agreement v_tmgi DATE; DECLARE v_ctdt DATE; DECLARE v_rvdt DATE; SET v_tmgi = '2014-09-01'; --Good month SET v_ctdt = '2012-06-02'; - CONTRACT_DT SET v_rvdt = v_ctdt; - v_rvdt initial value for WHILE (v_rvdt & lt; v_tmgi) - While the review DT is less than the month of DO SET v_rvdt = (v_rvdt + 5 YEAR); - Add up to date of 5 years; SET r_rvdt = v_rvdt; END Thanks!
Jimmy, thanks for your help, this is what I have created:
The process of making "X" "AL_LOOP_TEST" (outside "R_RVD" date) Language SQL fixed external procedure improvements SQL data Old Savings Pattern Start ATMs announcement v_tmgi DATE; DECLARE v_ctdt DATE; DECLARE v_rvdt DATE; SET v_tmgi = '2014-09-01'; --Good month SET v_ctdt = '2002-06-02'; - CONTRACT_DT SET v_rvdt = v_ctdt; - The initial value for v_rvdt WHILE (v_rvdt & lt; v_tmgi) - While the review DT is less than the month of DO SET v_rvdt = (v_rvdt + 5 YEAR); - Add up to date of 5 years; SET r_rvdt = v_rvdt; End;
Comments
Post a Comment