Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Julian Date 'YYYYDDD' into 'YYYYMMDD' 1

Status
Not open for further replies.

gotluru

Programmer
Oct 16, 2000
10
US
Date Manupulation. I have date in format 'YYYYDDD'.Can i use any date functions to convert into 'YYYYMMDD'. Please let me know.
[sig][/sig]
 
It depends if your compiler knows FUNCTION calls.
If it does, look up the right function. If it doesn't, you can write your own algorithm. [sig][/sig]
 
What version of COBOL are you running? If you do not have the function calls, I have a subroutine I could give you, about two pages of code total.

Betty Scherber
Brainbench MVP for COBOL II
[sig][/sig]
 
Hi Betty,

Thanks for your immediate response.

I don't know what version of Cobol is running. I hope i can use function calls. Can you Send Function and Source Code also. So, that i can implement one of those.

Thanks for all your help.

bye,
Prasad [sig][/sig]
 
Hi Crox,

Thanks for your immediate response.

I hope i can use function calls. Can you send Syntax for the Function.

Thanks for all your help.

bye,
Prasad [sig][/sig]
 
Hi,

FUNCTIONS are on the IBM manuals for free. See which has a pointer to the cobol manuals.

But here is something:

1.5.1.10 Function-Identifier
Ü Copyright IBM Corp. 1991, 1995

A function-identifier is a syntactically correct sequence of character
strings and separators that uniquely references the data item resulting
from the evaluation of a function.

|--- Format -------------------------------------------------------------|
| |
| >>--FUNCTION--function-name-1--|----------------------|--------------> |
| | <------------| | |
| |-(----argument-1-|--)-| |
| |
| >--|--------------------|------------------------------------------->< |
| |-reference-modifier-| |
| |
|------------------------------------------------------------------------|
argument-1
Must be an identifier, literal (other than a figurative constant), or
arithmetic expression.

For more information, see &quot;Intrinsic Functions&quot; in topic 7.1.

function-name-1
Function-name-1 must be one of the Intrinsic Function names.

reference-modifier
May be specified only for functions of the category alphanumeric


A function-identifier that makes reference to an alphanumeric function may
be specified anywhere that an identifier is permitted and where references
to functions are not specifically prohibited, except as follows:

* As a receiving operand of any statement

* Where a data item is required to have particular characteristics (such
as class and category, size, sign, and permissible values) and the
evaluation of the function according to its definition and the
particular arguments specified would not have these characteristics.


A function-identifier that makes reference to an integer or numeric
function may be used wherever an arithmetic expression is allowed.


7.1.15 DATE-OF-INTEGER
Ü Copyright IBM Corp. 1991, 1995

The DATE-OF-INTEGER function converts a date in the Gregorian calendar
from integer date form to standard date form (YYYYMMDD).

The function type is integer.

The function result is an eight-digit integer.

|--- Format -------------------------------------------------------------|
| |
| >>--FUNCTION DATE-OF-INTEGER--(argument-1)-------------------------->< |
| |
|------------------------------------------------------------------------|
argument-1
A positive integer that represents a number of days succeeding
December 31, 1600, in the Gregorian calendar. The valid range is 1 to
3,067,671, which corresponds to dates ranging from January 1, 1601
thru December 31, 9999.

| PICTURE 331 Under MVS and VM, the INTDATE installation option affects
| the starting date for the integer date functions. For details, see
| the IBM COBOL for MVS & VM Programming Guide. PICTURE 332



7.1.19 INTEGER-OF-DATE
Ü Copyright IBM Corp. 1991, 1995

The INTEGER-OF-DATE function converts a date in the Gregorian calendar
from standard date form (YYYYMMDD) to integer date form.

The function type is integer.

The function result is a seven-digit integer with a range from 1 to
3,067,671.

|--- Format -------------------------------------------------------------|
| |
| >>--FUNCTION INTEGER-OF-DATE--(argument-1)-------------------------->< |
| |
|------------------------------------------------------------------------|
argument-1
Must be an integer of the form YYYYMMDD, whose value is obtained from
the calculation (YYYY * 10,000) + (MM * 100) + DD.

* 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.



The returned value is an integer that is the number of days the date
represented by argument-1, succeeds December 31, 1600 in the Gregorian
calendar.

| PICTURE 335 Under MVS and VM, the INTDATE installation option affects the
| starting date for the integer date functions. For details, see the IBM
| COBOL for MVS & VM Programming Guide. PICTURE 336


7.1.20 INTEGER-OF-DAY
Ü Copyright IBM Corp. 1991, 1995

The INTEGER-OF-DAY function converts a date in the Gregorian calendar from
Julian date form (YYYYDDD) to integer date form.

The function type is integer.

The function result is a seven-digit integer.

|--- Format -------------------------------------------------------------|
| |
| >>--FUNCTION INTEGER-OF-DAY--(argument-1)--------------------------->< |
| |
|------------------------------------------------------------------------|
argument-1
Must be an integer of the form YYYYDDD whose value is obtained from
the calculation (YYYY * 1000) + DDD.

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

* DDD represents the day of the year. It must be a positive integer
less than 367, provided that it is valid for the year specified.


| PICTURE 337 Under MVS and VM, the INTDATE installation option affects
| the starting date for the integer date functions. For details, see
| the IBM COBOL for MVS & VM Programming Guide. PICTURE 338


The returned value is an integer that is the number of days the date
represented by argument-1, succeeds December 31, 1600 in the Gregorian
calendar.

The returned value represents the International Standards Organization
(ISO) standard date equivalent to the integer specified as argument-1.

The returned value is an integer of the form YYYYMMDD where YYYY
represents a year in the Gregorian calendar; MM represents the month of
that year; and DD represents the day of that month.


[sig][/sig]
 
Hi Betty,

it would be nice to see your code here!

thanks! :) [sig][/sig]
 
Hi Crox,

Thanks for your response.

I am planning to use:

COMPUTE GREG-DATE = FUNCTION INTEGER-OF-DAY
(FUNCTION DAY-OF-INTEGER(JUL-DATE))
END-COMPUTE.

Thanks,
Prasad [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top