Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Embedded sql - finding month difference

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Embedded sql - finding month difference
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: 686
Location: Earth

PostPosted: Thu Apr 19, 2007 11:45 pm    Post subject:
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    Post subject: Re: Embedded sql - finding month difference
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Finding IMS resource blocker after se... Hooman24 IMS DB/DC 1 Wed Aug 16, 2017 9:17 pm
No new posts Reg:Displaying the particular month o... bhavana yalavarthi All Other Mainframe Topics 4 Sat Jul 08, 2017 8:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us