IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Embedded sql - finding month difference


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Daphne

New User


Joined: 28 Aug 2006
Posts: 27
Location: NY, US

PostPosted: Thu Apr 19, 2007 11:18 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Apr 19, 2007 11:45 pm
Reply with quote

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
View user's profile Send private message
Daphne

New User


Joined: 28 Aug 2006
Posts: 27
Location: NY, US

PostPosted: Thu Apr 19, 2007 11:49 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Finding and researching jobs All Other Mainframe Topics 0
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts VB to FB - Finding LRECL SYNCSORT 4
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
Search our Forums:

Back to Top