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

Query not working ...


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

New User


Joined: 22 Aug 2005
Posts: 59
Location: india

PostPosted: Fri May 16, 2008 4:42 pm
Reply with quote

Code:
EXEC SQL
DECLARE CSR3_DOC CURSOR WITH HOLD FOR
SELECT
 DOC_CATEGORY_CODE
,DATE_TIME_PRODUCED
FROM
 TEJDOCD_DOC_DAT
WHERE
 DOC_CATEGORY_CODE = :TEJDOCD.DOC-CATEGORY-CODE
 AND (MONTHS(CURRENT DATE) – MONTHS(DATE(DATE_TIME_PRODUCED)))>:
TEJRFDC.DOC-RETENTION-PD
FOR
 FETCH ONLY
END-EXEC.



I need to find the difference between two dates in terms of months in this query.but iam getting SQL error -440.can u pls help me out .
Back to top
View user's profile Send private message
sathish_rathinam

New User


Joined: 22 Aug 2005
Posts: 59
Location: india

PostPosted: Fri May 16, 2008 4:50 pm
Reply with quote

Also ,

Code:
EXEC SQL
DECLARE CSR3_DOC CURSOR WITH HOLD FOR
SELECT
DOC_CATEGORY_CODE
,DATE_TIME_PRODUCED
FROM
TEJDOCD_DOC_DAT
WHERE
DOC_CATEGORY_CODE = :TEJDOCD.DOC-CATEGORY-CODE
AND (YEARS(CURRENT DATE) – YEARS(DATE(DATE_TIME_PRODUCED)))>:
TEJRFDC.DOC-RETENTION-PD
FOR
FETCH ONLY
END-EXEC. 

need to find the difference between two dates in terms of years in this query.but iam getting SQL error -440.can u pls help me out .
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri May 16, 2008 4:56 pm
Reply with quote

why dont' You try to help Yourself by looking at the manual

did You care to research the sqlcode ?

Quote:
sqlstate: 42884
message: No function or procedure was found with the specified name and compatible arguments.
sqlcode: -440


<something every poster should have read and understood read....>
Back to top
View user's profile Send private message
sathish_rathinam

New User


Joined: 22 Aug 2005
Posts: 59
Location: india

PostPosted: Fri May 16, 2008 5:00 pm
Reply with quote

can u pls tell me how to correct the sqls above as per my requirement
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Fri May 16, 2008 5:08 pm
Reply with quote

As per my knowledge, there is no MONTHS function in DB2. We can extract months using MONTH function and Years using YEAR function.

Please look at the following site. You can find for YEAR also.

publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0000830.htm

KSK
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Fri May 16, 2008 5:38 pm
Reply with quote

another post about month difference between two dates
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 RC query -Time column CA Products 3
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top