|
Rick Renkema <rick@createprint.com.au> wrote: >May I please retract the e-mail I posted re the Date difference problem Rick, you're not alone. Trying to do arithmetic with Julian dates is a very common error. I hate Julian dates. Avoid them like the plague. Once you cross the year boundary you run into all kinds of problems. In particular, be very aware that the standard Julian date format only has 2 characters for the year. The worst Julian date error I've seen in a live system was a custom program using CVTDAT from within J.D. Edwards, assuming that the Julian format was compatible with JDE's YYYDDD format and therefore re-introducing Y2K bugs into a Y2K compatible release of JDE. To do date arithmetic in RPG/III you need to obtain an absolute date based on some arbitrary starting value. The following code will get you a usable absolute date from a _long_ Julian date contained in numeric fields $YYYY and $DDD. It copes with leap years and leap centuries but does not take account of the Gregorian reform. C $YYYY SUB 1 ABS 70 C ABS DIV 100 $WK50 50 C ABS DIV 400 $WK50B 50 C MULT 365.25 ABS C SUB $WK50 ABS C ADD $WK50B ABS C ADD $DDD ABS No guarantees, so use at your own risk. Maybe Rick can find an error. :-) The sensible option, of course, is to use RPG/IV which has date data types and arithmetic built in. Dave Kahn, ABB Steward Ltd. +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.