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

How to increament date


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

New User


Joined: 14 Sep 2005
Posts: 54
Location: Chennai

PostPosted: Thu Aug 06, 2009 5:46 pm
Reply with quote

Hi
In my database i have a date field and i want to add 10 or 20 days to it.
how can i get this in COBOL or SQL?

Ex: WS-DATE = 2009-01-31(YYYY-MM-DD format)
WS-VAR = 10
and i want to add 10 days to
WS-DATE field to get WS-FINAL-DATE = 2009-02-10
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Aug 06, 2009 6:00 pm
Reply with quote

Use DATE(:WS-DATE) + 10 DAYS in your update ...
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Fri Aug 07, 2009 8:49 am
Reply with quote

Hi ,

Code:

SELECT  CURRENT TIMESTAMP                 
       ,WS-DATE - :WS-NUM  DAYS         
       ,WS-DATE + :WS-NUM-2 DAYS       
     
  INTO :WS-TSMP-X                         
      ,:WS-CUTOFF                     
      ,:WS-CUTOFF-DTE-2                   
               
  FROM  TABLE NAME
 WHERE  COL1 =  CURRENT DATE
                                 



May be this can help you
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Aug 07, 2009 8:56 am
Reply with quote

Hi Ketan,
Please read what OP wants.

He doesnt want to update only records with todays date..
Also what is COL1 in your query?
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Fri Aug 07, 2009 9:03 am
Reply with quote

Hi Sambhaji,
Correct me if I am wrong ,
In the above query I think he will able to add 10 or 20 day to the variable or the column he want to and COL1 is just a sample column name if there is some criteria of doing the operation. Thats just the sample one

Ketan
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Aug 07, 2009 9:11 am
Reply with quote

Hello,

Quote:
In the above query I think he will able to add 10 or 20 day to the variable or the column he want to
How would the posted query know about 10 or 20?

Please be much more careful when posting suggestions/solutions. Incomplete/incorrect info only makes things harder for the person who asked the question.
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Fri Aug 07, 2009 9:15 am
Reply with quote

Sorry Dick,
But what I understood from the question I tried answer to that I understood from the post. Please can some one make me understand what the requirement is basically .
I will take care in the coming future
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Aug 07, 2009 9:32 am
Reply with quote

Hello,

Quote:
Please can some one make me understand what the requirement is basically .

The post from Ashimer provides the answer to the question asked by Sashi. How to add a number of days to some date. . .
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
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 Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Fetch data from programs execute (dat... DB2 3
Search our Forums:

Back to Top