IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to calculate , Date= Date - Days


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 126
Location: India

PostPosted: Wed Apr 28, 2010 2:48 pm
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: 6966
Location: porcelain throne

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

Thx to guptae for this link:
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 28, 2010 4:27 pm
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: 126
Location: India

PostPosted: Wed Apr 28, 2010 4:37 pm
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: 6966
Location: porcelain throne

PostPosted: Wed Apr 28, 2010 4:38 pm
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: 6966
Location: porcelain throne

PostPosted: Wed Apr 28, 2010 6:04 pm
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: 126
Location: India

PostPosted: Wed Apr 28, 2010 6:10 pm
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: 6966
Location: porcelain throne

PostPosted: Wed Apr 28, 2010 7:08 pm
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: 126
Location: India

PostPosted: Fri Apr 30, 2010 1:54 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top