Last Day Scalar function
Posted: Thu Mar 10, 2011 1:34 am
My requirement is I need to get the 2 day of the current month.
I am using the below code to retrieve the 2nd day of the current month
LAST_DAY(TIMESTAMP(:WS-CUR-TIMESTAMP) - 1 MONTH) + :WS-VAR-MON-DAY DAYS)
The variable WS-CUR-TIMESTAMP has the timestamp value retrived from a table. The value WS-VAR-MON-DAYS keeps on changing. It can be 2,3 or 4 depending on the data retrieved from the table.
I populate WS-VAR-MON-DAY as
MOVE WS-VAR-VALUE to WS-VAR-MON-DAY
Where WS-VAR-VALUE is X(10).
I declared WS-CUR-TIMESTAMP as X(26) and WS-VAR-MON-DAYS as S9(10) COMP.
Because I am declaring the variable WS-VAR-MON-DAYS as COMP the data is not moving properly. Instead of value 2 it has 10245 some garbage value.
I tried decalring the varaible as numeric and alphanumeric but my program failed while compiling itself. I errored with undefined or unusable Host variable WS-VAR-MON-DAYS.
Can you please help me in this issue. I tried for the whole day and I was not able to identify the exact problem. Your help will be highly appreciated.
I am using the below code to retrieve the 2nd day of the current month
LAST_DAY(TIMESTAMP(:WS-CUR-TIMESTAMP) - 1 MONTH) + :WS-VAR-MON-DAY DAYS)
The variable WS-CUR-TIMESTAMP has the timestamp value retrived from a table. The value WS-VAR-MON-DAYS keeps on changing. It can be 2,3 or 4 depending on the data retrieved from the table.
I populate WS-VAR-MON-DAY as
MOVE WS-VAR-VALUE to WS-VAR-MON-DAY
Where WS-VAR-VALUE is X(10).
I declared WS-CUR-TIMESTAMP as X(26) and WS-VAR-MON-DAYS as S9(10) COMP.
Because I am declaring the variable WS-VAR-MON-DAYS as COMP the data is not moving properly. Instead of value 2 it has 10245 some garbage value.
I tried decalring the varaible as numeric and alphanumeric but my program failed while compiling itself. I errored with undefined or unusable Host variable WS-VAR-MON-DAYS.
Can you please help me in this issue. I tried for the whole day and I was not able to identify the exact problem. Your help will be highly appreciated.