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
 

 

How to calculate , Date= Date - Days

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

Active User


Joined: 17 Nov 2009
Posts: 122
Location: India

PostPosted: Wed Apr 28, 2010 2:48 pm    Post subject: How to calculate , Date= Date - Days
Reply with quote

Hi,

I am trying to subtract the days from current date,
where WS-ACK-PRD pic 9(3) contains the days.

I tried with below code but not working.
Please help.

EXEC SQL
SET :WS-CURRDT-MINUS-ACKPRD-DT = CURRENT DATE
- DAY(:WS-ACK-PRD )
END-EXEC
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Wed Apr 28, 2010 3:25 pm    Post subject:
Reply with quote

Thx to guptae for this link:
http://www.ibm.com/developerworks/data/library/techarticle/0211yip/0211yip3.html?S_TACT=105AGX01&S_CMP=TOPTEN

and here is a link to datetime arithmetic

by the way,
but not working is more a description of your attitude.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Wed Apr 28, 2010 4:27 pm    Post subject:
Reply with quote

Quote:
but not working.
This is very close to a null content statement. Do you mean:
1. the statement is accepted but not producing results?
2. the statement is accepted but producing incorrect results?
3. the statement is not accepted by DB2?
4. the statement caused DB2 to crash?
5. the statement caused an abend?
6. something else? if so, what?

Since you did not specify which of these possibilities occurred, are we to guess? Maybe solve your problem, maybe not? Wait for more information? Wait for you to learn how to pose a question?
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 122
Location: India

PostPosted: Wed Apr 28, 2010 4:37 pm    Post subject:
Reply with quote

Thanks everyone ,

It got solved now, I have corrected it by trial and error .

The correct syntax is as below..

EXEC SQL
SET :WS-CURRDT-MINUS-ACKPRD-DT = CURRENT DATE
- WS-ACK-PRD DAY
END-EXEC
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Wed Apr 28, 2010 4:38 pm    Post subject:
Reply with quote

try
- DAY(:WS-ACK-PRD) DAYS
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Wed Apr 28, 2010 6:04 pm    Post subject:
Reply with quote

are you sure it is:

- WS-ACK-PRD DAY

and not

- :WS-ACK-PRD DAY
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 122
Location: India

PostPosted: Wed Apr 28, 2010 6:10 pm    Post subject:
Reply with quote

Initially i tried with - :WS-ACK-PRD DAY
but gave compilation error.

Then I tired with - WS-ACK-PRD DAY
and it worked.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Wed Apr 28, 2010 7:08 pm    Post subject:
Reply with quote

Susanta,

thx for the feedback.
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 122
Location: India

PostPosted: Fri Apr 30, 2010 1:54 pm    Post subject:
Reply with quote

Really sorry to say that it gave bind error saying WS-ACK-PRD is not a known db2 column.

At last i used as below and compilation and bind was successfull.

SELECT CURRENT DATE - AC_PRD DAY
INTO :WS-CURRDT-MINUS-ACKPRD-DT
FROM TABL1
WHERE CNUM= :WS-CNUM
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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm


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