Here, try this:

$x is your Cobol integer days since 1800-1-1:

use Date::Calc;

# add the offset from 1800-1-1 to 1-1-1 (Date::Calc's "beginning of time")
$n = $x + Date_to_Days(1800,1,1);
($year, $month, $day) = Add_Delta_Days(1,1,1,$n - 1);

Then format $year, $month, $day to whatever form you want to save.
This should be much faster than Date::Manip.

-----Original Message-----
From: Jon S. Jaques [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 16, 2001 11:05 AM
To: [EMAIL PROTECTED]
Subject: Speaking of dates, how about converting a COBOL date?...


Hello Group,

I have a date field that I need to convert; It comes through as the number
of days since 1/1/1800... It comes from a Unix/COBOL sequential database
file, and performance is key, because there's 67,000 master records, each
with 3 or 4 of these fields, and then there are 8 other supporting tables
which each have some of these fields as well.

I did try Date::Manip, which seems to work, but is terribly slow; when I
engage those routines, I go from processing several hundred records per
second to only a couple per second, which is unacceptable.

Some of my ideas to handle it are:

* Slice and dice the files, leaving the date fields as they are, then...

either:

* Re-process the files, again with Perl, doing only the date fields... The
first run would be on a Linux box, but then the files would be moved to an
NT web server for the final pass.

OR

* The data is going into SQL 7... Maybe some sort of SQL trick to convert
the numbers to a date??? I'd like that, but can't quite see how it'd be
done.

Any ideas???

Thanks in advance!!!!

--Jon

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to