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: 331
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
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
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 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 Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm


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