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

How to find the current day


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

New User


Joined: 20 Jul 2006
Posts: 1
Location: Chennai

PostPosted: Tue Oct 24, 2006 2:23 pm
Reply with quote

Hi,
Is there any function in cobol to find out what day is today (ex : Friday or Satur day) based on the current date .

If any one knows please help me in this
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Oct 24, 2006 5:17 pm
Reply with quote

i dont think thr is ny cobol intrinsic date function available for this ...

use the following routine

IDENTIFICATION DIVISION.
PROGRAM-ID. WHATDAY.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 99 VALUE ZERO.
01 B PIC 9 VALUE ZERO.
01 C PIC 99 VALUE ZERO.
01 F VALUE "12060708091011".
05 FF PIC 99 OCCURS 7.
01 E PIC 9999 VALUE 2000.
01 T PIC 9999 VALUE ZERO.
01 I PIC 9 VALUE 1.
LINKAGE SECTION.
01 Y PIC 9(4).
01 M PIC 9(2).
01 D PIC 9(2).
01 DDY PIC X(3).
PROCEDURE DIVISION USING Y M D DDY.
0001A.
IF Y < 2000 DISPLAY "INVALID YEAR" GO 0000Z.
IF M < 1 OR > 12 DISPLAY "INVALID MONTH" GO 0000Z.
IF D < 1 OR > 31 DISPLAY "INVALID DATE" GO 0000Z.
MOVE D TO C.
0000X.
COMPUTE A = FF ( I ).
IF E = Y GO 0000Y.
ADD 1 TO I.
IF I > 7 COMPUTE I = 1.
DIVIDE E BY 4 GIVING T REMAINDER B.
IF E < Y AND B = 0 ADD 1 TO I.
IF I > 7 COMPUTE I = 1.
ADD 1 TO E.
GO 0000X.

0000Y.
IF B = 0 AND M > 2 ADD 1 TO A.
IF M = 1
ADD A TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 2
ADD A 3 TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 3
ADD A 3 TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 4
SUBTRACT 1 FROM A
ADD A TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 5
ADD A 1 TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 6
ADD A 4 TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 7
SUBTRACT 1 FROM A
ADD A TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 8
ADD A 2 TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 9
SUBTRACT 2 FROM A
ADD A TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 10
ADD A TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 11
ADD A 3 TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE IF M = 12
SUBTRACT 2 FROM A
ADD A TO D
DIVIDE D BY 7 GIVING A REMAINDER B
ELSE DISPLAY "DATA TYPE INVALID".
IF B = 0 MOVE "SUN" TO DDY
ELSE IF B = 1 MOVE "MON" TO DDY
ELSE IF B = 2 MOVE "TUE" TO DDY
ELSE IF B = 3 MOVE "WED" TO DDY
ELSE IF B = 4 MOVE "THU" TO DDY
ELSE IF B = 5 MOVE "FRI" TO DDY
ELSE IF B = 6 MOVE "SAT" TO DDY
ELSE DISPLAY "COBOL RUNTIME ERROR".
0000Z.
EXIT PROGRAM.

change as per ur need .....
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Tue Oct 24, 2006 5:49 pm
Reply with quote

if LE available read about CEEDYWK?calculate day of week from Lilian date:

publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=/com.ibm.aix.cbl.doc/rpsrv15.htm
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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts Changeman - how can we know the curr... Compuware & Other Tools 2
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Find the size of a PS file before rea... COBOL Programming 13
Search our Forums:

Back to Top