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
 

 

Date query with 15 days behind

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
AJAYREDDY

New User


Joined: 17 Feb 2007
Posts: 47
Location: USA

PostPosted: Tue Sep 22, 2015 1:17 am    Post subject: Date query with 15 days behind
Reply with quote

I need data from a DB2 table from given date back to 10 days.

For example if I give date as 09/18/2015 - 10 days I need only all the records from 10 days behind 09/18/2015.

I am trying this query but its failing. I seen examples for CURRENT DATE - 10 days but not for ANY GIVEN DATE - 10 days. Can someone please let me know the query.

SELECT * FROM QUAL.MYTABLE WHERE DATE_COL >= '09/18/2015' - 10 DAYS;
Back to top
View user's profile Send private message

RahulG31

Active User


Joined: 20 Dec 2014
Posts: 335
Location: USA

PostPosted: Tue Sep 22, 2015 2:52 am    Post subject: Reply to: Date query with 15 days behind
Reply with quote

Use DATE function. Try this:

Code:
SELECT * FROM QUAL.MYTABLE WHERE DATE_COL >= DATE('09/18/2015') - 10 DAYS;


.
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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