Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us