Page 1 of 1

Getting predated or post dated date from Sysdummy1.

PostPosted: Mon Jul 23, 2012 7:30 pm
by gokulNmf
Hi,
This is how we used to get date from SYSIBM.SYSDUMMY1 table,
SELECT DATE(CURRENT DATE + 1 DAYS),
 INTO :WS-MON-DATE-DB2,
 FROM SYSIBM.SYSDUMMY1
 WITH UR;


Now my requirement is, if suppose on the particular day i am not able to run the program as scheduled, i want to run program on later date by giving the past date through a parm to the program. But how to pass that value to this table to get the date? I tried the below code, but its giving error while binding. (-182, -171). Is there any way to achieve this?

SELECT DATE(:WS-CURRENT-DATE-DB2-H + 1 DAYS),
INTO :WS-MON-DATE-DB2,
FROM SYSIBM.SYSDUMMY1
WITH UR

Re: Getting predated or post dated date from Sysdummy1.

PostPosted: Mon Jul 23, 2012 8:06 pm
by Akatsukami
And :WS-CURRENT-DATE-DB2-H is defined as...?

Re: Getting predated or post dated date from Sysdummy1.

PostPosted: Mon Jul 23, 2012 10:55 pm
by gokulNmf
I am sorry, i dint mention it.

WS-CURRENT-DATE-DB2-H pic x(10) and i am moving the date in 'yyyy-mm-dd' format to it.

Re: Getting predated or post dated date from Sysdummy1.

PostPosted: Tue Jul 24, 2012 12:35 am
by Akatsukami
I believe that the problem is that COBOL doesn't have any equivalent data type to a DB2 DATE INTERNAL; it is thus necessary to cast the character string to a date before attempting to perform date arithmetic on it. Try:

SELECT DATE(:WS-CURRENT-DATE-DB2-H)+ 1 DAYS
INTO :WS-MON-DATE-DB2
FROM SYSIBM.SYSDUMMY1
WITH UR

Re: Getting predated or post dated date from Sysdummy1.

PostPosted: Tue Jul 24, 2012 8:53 am
by gokulNmf
And what you believed is true Akatsukami, its the problem with datatype, i tried the below one as you suggested, by just tweaking, and it just worked fine :D .
EXEC SQL                                             
    SELECT DATE(DATE(:WS-CURRENT-DATE-DB2-H)+ 1 DAYS)
      INTO :WS-MON-DATE-DB2                         
      FROM SYSIBM.SYSDUMMY1                         
END-EXEC                                             


Thanks for the reply!