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

Question on Date Manipulation in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Piyari

New User


Joined: 19 Nov 2007
Posts: 4
Location: India

PostPosted: Mon Nov 19, 2007 11:43 am
Reply with quote

Hi,

I have a requirement to see if a particular date falls within 3 years from the current date.

My input date is in CYYMMDD format. (eg, 3031201). We need to check if this date falls within 3 years from the Current date.

Pls share your thoughts on how best this could be accompolished.

Our installation uses VS COBOL II.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Nov 19, 2007 11:56 am
Reply with quote

Piyari,

Quote:
My input date is in CYYMMDD format. (eg, 3031201).


Generally the value of 'C' is taken either 0 (for 19XX years) or 1 (for 20XX).

How did you get 3?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Mon Nov 19, 2007 12:40 pm
Reply with quote

Piyari,

Welcome to the forums.

Quote:
Pls share your thoughts on how best this could be accompolished.


It can be done using SORT. Also search the DFSORT forum for similar topics. . Try this JCL and change the same as per your requirement.

Code:
//S1    EXEC  PGM=ICEMAN                                             
//SYSOUT    DD  SYSOUT=*                                             
//SORTIN DD *                                                         
RECORD                                                               
/*                                                                   
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)       
//SYSIN    DD    *                                                   
  OPTION COPY                                                         
  INREC OVERLAY=(21:DATE1,                                           
    1:C'YEAR,''',23,2,ZD,SUB,+3,EDIT=(TT),25,4,C'''',21:60X)         
/*                                                                   
//S2    EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                           
//SORTIN DD *                                                     
1031115                                                           
1051119                                                           
1061119                                                           
1071119                                                           
1031115                                                           
1041119                                                           
/*                                                               
//SORTOUT DD SYSOUT=*                                             
//SYSIN    DD    *                                               
  OPTION COPY                                                     
  INCLUDE COND=(2,6,CH,GE,YEAR)                                   
/*                                                               


output:

Code:
1051119                                             
1061119                                             
1071119                                             
1041119                                             
Back to top
View user's profile Send private message
Piyari

New User


Joined: 19 Nov 2007
Posts: 4
Location: India

PostPosted: Fri Nov 23, 2007 12:55 pm
Reply with quote

Murali,

Answering your question, our programs have been coded in a such a way that '2' corresponds to 19XX years & ' 3' corresponds to 20XX years.

Aaru,

Thanks for your suggestion. I accompolished it with cobol logic itself.

First i converted the input date to YYYYMMDD format.
Then i subtracted 3 years from the Current date and checked if input date was greater than that.

Since the number of input records in the input file is not huge,this should do the trick for me!
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Fri Nov 23, 2007 12:59 pm
Reply with quote

Piyari,

Good you got your req.

Also its very pleasing to know, you dint forget to reply back and following the post even after a week.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Nov 27, 2007 11:41 pm
Reply with quote

Hi Piyari,


I don't know the full reqs of your problem, but did you account for leap year?
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top