Adabas Date Field Data Equivalent

Hi,

I have a Date Field in Adabas having data type as Date and value as number like 730406.
How to convert this number (730406) into equivalent MM/DD/YYYY format?
Is this any mechanism\algorithm for this?

Thanks in advance for the help.

Regards,
Santosh

Is this Adabas on the mainframe or LUW (Linux / Unix / Windows) ?

You actually have a P4 in Adabas and D format for Natural if it contains a value like 730406.

Best thing you can do is read it with a Natural program which uses a DDM that points to this file and maps the shortname of this field to a D format DDM field. Then just read the file and display!

If you for some reason can’t use Natural, this is the number of days since a point of origin (Jan 2, year zero), and you can determine the date it represents by advancing that many days from the point of origin, ignoring actual changes in the calendar over time and ignoring the fact there was no such thing as year zero.

Today is 734807 (2 Nov 2011).

BTW, if you do this correctly, you can party like it’s 1999 because you will get 15 October 1999 as the answer.

Hi Brian,

Thank you very much for the prompt reply. This helps a lot.
I am not a Natural expert hence I am asking for one more help.
If you have the sample natural progarm ready with you that will do this converion, can you share the same?
That will be of great help.

Thanks once again for helping.
Really appreciated.

Regards,
Santosh

What Brian said is:

define the date field as format ‘D’(ate) in the DDM / View,
no extra conversion is required as Natural will do that for you.

Take the “BIRTH” field in DDM EMPLOYEES for an example, this is defined
as format ‘D’, now create a simple program to read a few Employees
records and WRITE the BIRTH field.

Regards,
Wolfgang

Hi Santosh,

Your Natural DDM (for the Adabas file) should already have it defined as format D. You can verify it using “L V ddm-name” command, if so just write a simple program as below written for EMPLOYEES file given by SAG.

The below code is written in Reporting Mode (that can be invoked with GLOBALS SM=OFF command)

READ(10) EMPLOYEES
*   WHERE BIRTH NE 0
  DISPLAY BIRTH
END

*WHERE clause is written and can be used in case first 10 records are retrieved as 0 or blank

If you actually require an alpha field with the date, you can use some variation on the code below:

DEFINE DATA LOCAL
1 #DATE-ALPHA (A8)
END-DEFINE
*
MOVE EDITED *DATX (EM=YYYYMMDD) TO #DATE-ALPHA
WRITE ‘=’ #DATE-ALPHA
END
Page 1 11/03/11 06:49:00

#DATE-ALPHA: 20111103

You can also redefine #DATE-ALPHA as #DATE-N (N8) and then redefine that to individual fields
with numeric values for month and day and year.

steve

As an add-on to the code above, if you require the slashes in the alpha date field,

DEFINE DATA LOCAL
1 #DATE-ALPHA (A10)
END-DEFINE
*
MOVE EDITED *DATX (EM=MM’/‘DD’/'YYYY) TO #DATE-ALPHA
WRITE ‘=’ #DATE-ALPHA
END

Page 1 11/03/11 06:55:17

#DATE-ALPHA: 11/03/2011

steve