Page 1 of 1

Natural date type correspondence

PostPosted: Tue Jun 04, 2013 9:46 pm
by tivrfoa
Hi,

The data in ADABAS is D 6. When a display it in a Natural program it shows in the format ddmmyyyy.
I call the program from JCL that writes this data to a dataset, but I don't know what to use in EDIT for this type.
I tried BI, FI, and others without success. What I must use with OUTREC EDIT?

The Natural program simply writes the data direct from the view:
READ CDA060
WRITE WORK FILE 1 CDA060
END-READ

Thank you.

Re: Natural date type correspondence

PostPosted: Tue Jun 04, 2013 11:36 pm
by tivrfoa
For example, it displays 11122012 in Natural, and when I use 42,04,PD,EDIT=(TTTTTTTT) it becomes 00735212.

Re: Natural date type correspondence

PostPosted: Tue Jun 04, 2013 11:54 pm
by dick scherrer
Hello,

Suggest you show the date in HEX (in ADABAS). I suspect it is not PD.

Re: Natural date type correspondence

PostPosted: Tue Jun 04, 2013 11:59 pm
by tivrfoa
dick scherrer wrote:Hello,

Suggest you show the date in HEX (in ADABAS). I suspect it is not PD.


I set hex on in the dataset before the SORT.
Natural: 11122012
Hex:
0322
751F

Re: Natural date type correspondence

PostPosted: Wed Jun 05, 2013 12:58 am
by dick scherrer
Well, that value is valid for a packed-decimal field. It is not however, the way many(most) PD dates are stored.

Look in the ADADBAS documentation for an explanation of how this date is stored. It may be the difference in days from some control date.

Re: Natural date type correspondence

PostPosted: Wed Jun 05, 2013 11:22 pm
by Akatsukami
It looks like the number of days since 1 Jan 1 CE.

Re: Natural date type correspondence

PostPosted: Thu Jun 06, 2013 2:51 am
by tivrfoa
Akatsukami wrote:It looks like the number of days since 1 Jan 1 CE.

Nice observation.
I checked in this site: http://www.timeanddate.com/date/duration.html

And got:

PD,EDIT NATURAL DAYS IN SITE
00735212 -> 11122012 ->>> 734,849
00735187 -> 16112012 ->>> 734,824
00733848 -> 18032009 ->>> 733,485

Now I'll try to find a way to convert this date in days to this format ddmmyyyy.
Thank you.

Re: Natural date type correspondence

PostPosted: Thu Jun 06, 2013 3:11 pm
by Akatsukami
The number of days between 1 Jan 1 CE in the Julian calendar and 15 Oct 1582 CE in the Gregorian calendar (which is Lilian day 1) is 577,737. Depending on what language you're using, you may be able to subtract that number minus one from the date and then use the LE function CEEDATE to get a Gregorian date.

Re: Natural date type correspondence

PostPosted: Fri Jun 14, 2013 8:55 pm
by tivrfoa
Akatsukami wrote:The number of days between 1 Jan 1 CE in the Julian calendar and 15 Oct 1582 CE in the Gregorian calendar (which is Lilian day 1) is 577,737. Depending on what language you're using, you may be able to subtract that number minus one from the date and then use the LE function CEEDATE to get a Gregorian date.

Thank you Akatsukami.
I went to the link you gave and CEEDATE function needs to called from a program, so it was simple to convert in the Natural program:
MOVE EDITED DT-PEDIDO-060(EM=DDMMYYYY) TO #DT-PEDIDO-060

I looked if Syncsort can do this, but couldn't find a way.

Thanks again.