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

BETWEEN Clause for DATE columns


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

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue May 14, 2013 6:00 pm
Reply with quote

Hi All,

I am trying to Select data for 6 days from a DB2 Table in a Cobol program

WHERE clause I am providing is as below

Code:
WHERE DATE_COLUMN BETWEEN (:WS-INPUT-DATE - 6 DAYS) AND :WS-INPUT-DATE


But this is giving sql error code as -401

This query works fine in SPUFI

Here WS-INPUT-DATE coming from Input file

I tried like below as well
Code:
WHERE DATE_COLUMN BETWEEN DATE (DAYS(:WS-INPUT-DATE) - 6 DAYS) AND :WS-INPUT-DATE


But still no luck..

If I calculate WS-INPUT-DATE - 6 days outside sql query and provide it as Host variable it works fine.

I am just looking for if I am missing something and it's possible in Db2 query itself

Thanks in advance

Regards,
Chandan
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue May 14, 2013 6:15 pm
Reply with quote

Hi Guys,

My bad I got the soulution for this

I changed it as below

Code:
WHERE DATE_COLUMN BETWEEN DATE (DAYS(:WS-INPUT-DATE) - 6 ) AND :WS-INPUT-DATE


I should have used 6 instead of 6 days

Regards,
Chandan
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue May 14, 2013 7:54 pm
Reply with quote

Good to hear it is working - thank you for posting the resolution icon_smile.gif

d
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top