× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Time Math in RPGLE
  • From: Scott Klement <klemscot@xxxxxxxxxxxx>
  • Date: Mon, 31 Jul 2000 18:23:54 -0500 (CDT)



On Mon, 31 Jul 2000, Rob Berendt wrote:

> Ok, so what you are trying to receive is some sort of duration 
> field with one possible definition being 
>years-months-days-hours-minutes-seconds 
> like the following:
> timestamp1 subdur timestamp2  duration:*x
> where *x would define the format
> such as (forgive me if the format or duration is not exact)
> '2000-01-31-12:10:15' subdur '1999-12-31-10:10:05'  duration:*x
> and duration would equal 0-01-00-02:00:10 for 0 years, 1 month, 0 days, 2 
>hours, 
> 0 minutes and 10 seconds,  So this wouldn't be a timestamp, or a time either 
>would it?
> 
> If this is true, then this should be simple to construct your own bif using a 
> subprocedure.  But if you did, I would use subdur's to figure out each part 
>by 
> checking for decimals or remainders or some such thing.
> 
> Are we on the right track, at least to what result you are looking for?
> 
> 

Yes, it appears you now understand what the original poster was trying to
do.  Except, that she wasn't interested in years, months, days... just
hours and minutes.   Two days would be 48 hours, 3 days would be 72 hours,
with the remainder in minutes.  

I, however, am not looking for anything.  I posted a solution to her
problem, which apparently you felt could've been done better?  I'm 
basing that assumpting on the fact that you're still talking about it. :)

You can't use SUBDURs to figure out "each part."  If we take your original
example, and try to "figure out each part" with SUBDUR, this is what we
get:
   
   z'2000-01-31-12.10.15' subdur z'1999-12-31-10.10.05'  hours:*H
      yields 746 hours

   z'2000-01-31-12.10.15' subdur z'1999-12-31-10.10.05'  hours:*H
      yields 44760 minutes  

Unfortunately, we weren't looking for a result of "746 hours and 44760
minutes"  we were looking for a result of "746 hours and 0 minutes" 
(...plus 10 seconds, but we werent concerned about that...)

So that leads us to a solution like this:

     D timestamp1      S               Z
     D timestamp2      S               Z
     D RawMinutes      S             10I 0
     D Hours           S             10I 0
     D Minutes         S             10I 0

      ** ...code to put data into timestamps goes here....

     c     timestamp2    subdur    timestamp1    RawMinutes:*MN
     c     RawMinutes    div       60            Hours
     c                   mvr                     Minutes

      **  ...etc...


WOW!  Wish I had thought of that --- OH WAIT, I DID!  What do you know?!
THATS THE EXACT SAME CODE THAT I POSTED ALMOST TWO DAYS AGO!  

Solutions are pretty useless without problems.


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-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 thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.