date-time conversion



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

date-time conversion

Postby halfrida » Fri Jul 23, 2010 4:37 pm

I want to convert date-time n yyyymmdd format to integer format.
I found this function called "integer of date" from IBMMAINFRAMES.COM

My piece of code is as follows....

WORKING-STORAGE SECTION.
01 DATE-TIME.
05 WS-CC PIC 99 VALUE 19.
05 WS-YY PIC 99 VALUE 98.
05 WS-MM PIC 99 VALUE 06.
05 WS-DD PIC 99 VALUE 17.
05 WS-HH PIC XX VALUE '10'.
05 WS-MM PIC XX VALUE '45'.
05 WS-SS PIC XX VALUE '21'.
05 WS-SSHH PIC XX VALUE '04'.
01 OUTPUT1 PIC 9(16).

PROCEDURE DIVISION.
MAIN-PARA.
COMPUTE OUTPUT1 = FUNCTION INTEGER-OF-DATE(DATE-TIME)
DISPLAY OUTPUT1.
STOP RUN.


I get an abend stating the following message.

"Function argument "DATE-TIME" did not have the correct
type for function "INTEGER-OF-DATE". The statement was
discarded."


I would be grateful if sumone solves this issue...
Thanks in advance :)
halfrida
 
Posts: 9
Joined: Mon Jun 07, 2010 12:19 pm
Has thanked: 0 time
Been thanked: 0 time

Re: date-time conversion

 

Re: date-time conversion

Postby Robert Sample » Fri Jul 23, 2010 4:50 pm

If you had bothered to read the manual (easily accessible at your referenced web site), you would have found
argument-1
Must be an integer of the form YYYYMMDD, whose value is obtained from the calculation (YYYY * 10,000) + (MM * 100) + DD, where:

* YYYY represents the year in the Gregorian calendar. It must be an integer greater than 1600, but not greater than 9999.

* MM represents a month and must be a positive integer less than 13.

* DD represents a day and must be a positive integer less than 32, provided that it is valid for the specified month and year combination.
Remove the hours, minutes, seconds and SSHH fields from your DATE-TIME variable and try again.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: date-time conversion

Postby halfrida » Fri Jul 23, 2010 5:15 pm

WORKING-STORAGE SECTION.
01 DATE-TIME.
05 WS-CC PIC 99 VALUE 19.
05 WS-YY PIC 99 VALUE 98.
05 WS-MM PIC 99 VALUE 06.
05 WS-DD PIC 99 VALUE 17.
01 OUTPUT1 PIC 9(16).

PROCEDURE DIVISION.
MAIN-PARA.
COMPUTE OUTPUT1 = FUNCTION INTEGER-OF-DATE(DATE-TIME)
DISPLAY OUTPUT1.
STOP RUN.


I have deleted those lines and compiled...
Still i get the same error....
halfrida
 
Posts: 9
Joined: Mon Jun 07, 2010 12:19 pm
Has thanked: 0 time
Been thanked: 0 time

Re: date-time conversion

Postby Robert Sample » Fri Jul 23, 2010 5:25 pm

Are you aware that "integer" in the context of the manual quote means a PIC 9(08) variable? Using a group level as you are doing is not allowed -- hence the compile error. Either use a REDEFINES or MOVE the group level variable to an elementary variable.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: date-time conversion

Postby halfrida » Fri Jul 23, 2010 5:48 pm

Thanks a lot i changed the data size and its workin fine now...
halfrida
 
Posts: 9
Joined: Mon Jun 07, 2010 12:19 pm
Has thanked: 0 time
Been thanked: 0 time

Re: date-time conversion

Postby halfrida » Fri Jul 23, 2010 6:20 pm

Is there any way in the same manner mentioned above or other ways to convert time to integer in COBOL.
halfrida
 
Posts: 9
Joined: Mon Jun 07, 2010 12:19 pm
Has thanked: 0 time
Been thanked: 0 time

Re: date-time conversion

Postby Robert Sample » Fri Jul 23, 2010 7:38 pm

What do you mean "convert time to an integer in COBOL"? COBOL does not have an facility to deal with time, so if you define a PIC 9(06) variable and place 103004 in it, that can be considered a time value -- but COBOL would also consider 739169 the same way (as a six-digit integer). There is probably some facilities in LE to handle time values ,but native COBOL does not do so.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: date-time conversion

Postby dick scherrer » Fri Jul 23, 2010 11:08 pm

Hello,

What do you want to do with time?

If you explain precisely what you want to do rather than some generic question, someone may have a suggestion. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: date-time conversion

Postby halfrida » Mon Jul 26, 2010 8:32 am

I'm in the process of creating a function that convert current date and time into integer form....
I came up with a solution for date , which i have posted above....Can sum one help me out in figuring out the solution for time...
halfrida
 
Posts: 9
Joined: Mon Jun 07, 2010 12:19 pm
Has thanked: 0 time
Been thanked: 0 time

Re: date-time conversion

Postby dick scherrer » Mon Jul 26, 2010 10:06 am

Hello,

Probably - if you explain how you intend to use the converted value. . . Read my earlier reply . . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post