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
This topic is locked: you cannot edit posts or make replies. Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts Finding the plan when code compiled u... Ahemad DB2 2 Fri Dec 01, 2017 6:38 pm
No new posts Finding difference between two PS fil... Vignesh Sid SYNCSORT 5 Mon Oct 30, 2017 1:13 pm
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm

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