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
 

 

year calculation in date field with numeric value in sql??

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Sanath sekhar Reddy N

New User


Joined: 31 Oct 2012
Posts: 31
Location: INDIA

PostPosted: Mon Mar 25, 2013 8:48 pm    Post subject: year calculation in date field with numeric value in sql??
Reply with quote

Hi

Iam having requirement of below query.

to add date to the numeric value and compare with the date .
like as below

start-date + term < = 01.04.2013

where for eg start-date is 01.01.1998 and term is value 14 ,then 01.01.1998 + 14 years = 01.01.2012 < = 01.04.2013 ,then this record should be extracted in output from database table.
how to query this in sql,pls help me


regards
Sanath
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1746
Location: Bloomington, IL

PostPosted: Mon Mar 25, 2013 9:01 pm    Post subject:
Reply with quote

So what are the columns of the table and the host variables? (Names and definitions, please).
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Mon Mar 25, 2013 9:08 pm    Post subject:
Reply with quote

Sanath,


Please try below mentioned SQL


Code:
select * from table_name
where
date(Start_date) + 14 Year <= '2013-01-04'
Back to top
View user's profile Send private message
Sanath sekhar Reddy N

New User


Joined: 31 Oct 2012
Posts: 31
Location: INDIA

PostPosted: Mon Apr 01, 2013 5:18 pm    Post subject: Thanks Sai Prasadh
Reply with quote

Hi

I have tried this

select * from table_name
where
Date-field + 14 Year <= '2013-01-04'

This worked.

Thanks Sai for the timely response, Thanks to Akatsukami
also who responded in time .
Thank you very much.

Regards
Sanath sekhar reddy
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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
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


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