HP3000-L Archives

February 2006, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Tracy Pierce <[log in to unmask]>
Reply To:
Tracy Pierce <[log in to unmask]>
Date:
Wed, 8 Feb 2006 14:49:23 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (114 lines)
Eben, I already sent you my arduously bullet-proofed dtdif routine, but
it calcs exact days.  for the calc you requested, try

01  jafemaapmajujuauseocnode value 
   '312831303130313130313031'.
    05  days occurs 12.
01  date1.
    05  d1ccyy pic 9999.
    05  d1mm   pic 99.
    05  d1dd   pic 99.
01  date2.
    05  d2ccyy pic 9999.
    05  d2mm   pic 99.
    05  d2dd   pic 99.
01  diff.
    05  dify   pic 9999.
    05  difm   pic 99.
    05  difd   pic 99.


if date1 < date2
  display 'please enter dates in ascending sequence'
else
  if  d1dd < d2dd    
    subtract 1 from d1mm
    add days ( d1mm ) to d1dd
    if  ( d1mm > 2 or ( d1mm = 2 and d1dd > 28 ))
    and ( d1ccyy / 4 * 4 = d1ccyy )
    and not ( d1ccyy / 400 * 400 = d1ccyy )
*     *d1 is a leap year; this is not pseudo code, it works.
      add 1 to d1dd
    end-if
  end-if
  compute difd = d1dd - d2dd
  if  d1mm < d2mm
      subtract 1 from d1yy
      add 12 to d1mm
  endif
  compute difm = d1mm - d2mm
  compute dify = d1ccyy - d2ccyy
  display 'difference is ' dify ' years, ' difm ' months, ' difd '
days.'
end-if
.  


Tracy Pierce, GGBHTD

 

> -----Original Message-----
> From: Tracy Pierce 
> Sent: Wednesday, February 08, 2006 2:21 PM
> To: 'Eben Yong'
> Subject: RE: HP COBOL routine to calculate the difference 
> between 2 dates
> 
> see prior.  after reading the explanation, it occurs to me 
> that it could be a lot simpler to state:
> 
> 01  date1 pic s9(9) comp.
> 01  date2 pic s9(9) comp.
> 01  diff  pic s9(9) comp.
> 
> move 19530202 to date1
> move 20060208 to date2
> move zero     to diff
> call dtdif using date1 date2 diff
> *diff holds my age in days.
> 
> or
> 
> move 19530202 to date1
> move 0        to date2
> move 365      to diff
> *date2 holds the date 365 days after date1.
> 
> > -----Original Message-----
> > From: HP-3000 Systems Discussion 
> > [mailto:[log in to unmask]] On Behalf Of Eben Yong
> > Sent: Wednesday, February 08, 2006 1:44 PM
> > To: [log in to unmask]
> > Subject: HP COBOL routine to calculate the difference 
> between 2 dates
> > 
> > I'm slightly embarrassed to even post this question, as I 
> > feel I should be 
> > able to produce this code in a snap, but for some reason my 
> > brain must be 
> > somewhat tired today.  In any event, excuses aside, here is 
> > the question:
> > 
> > Would someone pls share their COBOL code that will calculate the 
> > difference between two given dates, and return the results in 
> > terms of 
> > years, months, and days?
> > 
> > For example, the difference between 20060125 and 20040611 
> is 1 year 7 
> > months and 14 days.  
> > 
> > Care to share?  
> > Thanks as always,
> > Eben Yong
> > Health Plan of San Mateo
> > 
> > * To join/leave the list, search archives, change list settings, *
> > * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
> > 
> 

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2