Page 1 of 1

date-time conversion

PostPosted: Fri Jul 23, 2010 4:37 pm
by halfrida
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 :)

Re: date-time conversion

PostPosted: Fri Jul 23, 2010 4:50 pm
by Robert Sample
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.

Re: date-time conversion

PostPosted: Fri Jul 23, 2010 5:15 pm
by halfrida
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....

Re: date-time conversion

PostPosted: Fri Jul 23, 2010 5:25 pm
by Robert Sample
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.

Re: date-time conversion

PostPosted: Fri Jul 23, 2010 5:48 pm
by halfrida
Thanks a lot i changed the data size and its workin fine now...

Re: date-time conversion

PostPosted: Fri Jul 23, 2010 6:20 pm
by halfrida
Is there any way in the same manner mentioned above or other ways to convert time to integer in COBOL.

Re: date-time conversion

PostPosted: Fri Jul 23, 2010 7:38 pm
by Robert Sample
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.

Re: date-time conversion

PostPosted: Fri Jul 23, 2010 11:08 pm
by dick scherrer
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. . .

Re: date-time conversion

PostPosted: Mon Jul 26, 2010 8:32 am
by halfrida
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...

Re: date-time conversion

PostPosted: Mon Jul 26, 2010 10:06 am
by dick scherrer
Hello,

Probably - if you explain how you intend to use the converted value. . . Read my earlier reply . . .