View previous topic :: View next topic
|
Author |
Message |
Daphne
New User
Joined: 28 Aug 2006 Posts: 27 Location: NY, US
|
|
|
|
Hi all,
I am trying to find the number of months between two days in an embedded SQL query. The query is as below.
EXEC SQL
SELECT
MONTH(:WS-CALL-DT)
- MONTH(:WS-START-DT)
INTO :WS-MONTH-DIFF
FROM SYSIBM.SYSDUMMY1
END-EXEC
Now I had defined the host variable WS-MONTH-DIFF as PIC X(03) , since I dont expect more than 2 years of difference between these two dates.
But I am getting -303 while execution.
Can someone help me identify the problem here. I see that -303 is with invalid host variable. But not sure how to define this variable.
Thanks in advance,
Daphne |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
result of MONTH function is a large integer. You have declared host variable as X(03). Getting hint..S9..?
Quote: |
I am trying to find the number of months between two days in an embedded SQL query |
I don't think you are doing that either. What if Year part of two dates are different? |
|
Back to top |
|
|
Daphne
New User
Joined: 28 Aug 2006 Posts: 27 Location: NY, US
|
|
|
|
Hi Abhijit,
Thanks for your reply.
My statement should have been "different between two dates" not "two days". Sorry about the typo.
As you mentioned I tried using S9(04) comp-3 and now it works fine.
Thank you,
Daphne |
|
Back to top |
|
|
|