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 Arithmetic with String obtained with SELECT

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

New User


Joined: 06 Jan 2010
Posts: 9
Location: Lisbon, Portugal

PostPosted: Fri Mar 12, 2010 8:21 pm    Post subject: Date Arithmetic with String obtained with SELECT
Reply with quote

Hello,

I need to build a query to use in an UNLOAD that fetches all registers with timestamp older than X days old, where X is a CHAR variable in one of our tables.

Is this possible? I have been trying:

WHERE TS_field < CURRENT_DATE -
(SELECT X_Char_Field
from PARAM_TABLE
where pk = 'yaddayadda') DAYS

I have also tried with (...) CURRENT_DATE - DEC(SELECT (...), but I keep getting syntax errors.

Can anywone recommend a way to do this?

Thanks,
Henrique
Back to top
View user's profile Send private message

GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Fri Mar 12, 2010 9:17 pm    Post subject:
Reply with quote

Code:
...WHERE TS_field < CURRENT_DATE -
(SELECT integer(X_Char_Field)
from PARAM_TABLE
where pk = 'yaddayadda') DAYS


Manual wrote:
The result is the same number that would result from CAST(string-expression
AS INTEGER). Leading and trailing blanks are eliminated and the resulting
string must conform to the rules for forming an integer constant. If the whole
part of the argument is not within the range of integers, an error is returned.
Back to top
View user's profile Send private message
henriquecosta

New User


Joined: 06 Jan 2010
Posts: 9
Location: Lisbon, Portugal

PostPosted: Fri Mar 12, 2010 9:30 pm    Post subject:
Reply with quote

Hi,

Worked great, thanks!!
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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 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
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm


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