|
-----Original Message----- From: Peter Dow [mailto:maillist@xxxxxxxxxxxxxxx] Sent: Monday, March 31, 2003 1:45 PM To: RPG programming on the AS400 / iSeries Subject: Re: Finding the Elapsed time between two date fields Hi Andy, I assume you meant either timestamps or time fields, since date fields won't accept time values. What you're missing is that the difference in minutes between 16:26:57 and 18:09:04 is 102. The difference in seconds is 6,127. You could expand your result fields temporarily to see this (i.e. 6.0 instead of 2.0). To obtain the result you want, you could calculate it from the elapsed seconds: d time1 s t inz(t'16.26.57') d time2 s t inz(t'18.09.04') d ElapsedSec s 6p 0 d ElapsedTime s t d Result ds d hrs 2s 0 d min 2s 0 d sec 2s 0 /free ElapsedSec = %diff(Time2:Time1:*S); ElapsedTime = t'00.00.00' + %seconds(ElapsedSec); hrs = %subdt(ElapsedTime:*H); min = %subdt(ElapsedTime:*MN); sec = %subdt(ElapsedTime:*S); dsply result; /end-free hth, Peter Dow Dow Software Services, Inc. 909 793-9050 voice 909 522-3214 cellular 909 793-4480 fax ----- Original Message ----- From: "Andy Hautamaki" <ahautamaki@xxxxxxxxxxxxxxx> To: <RPG400-L@xxxxxxxxxxxx> Sent: Monday, March 31, 2003 9:56 AM Subject: Finding the Elapsed time between two date fields > I have two date fields *MDY with these values. '18:09:04' and '16:26:57'. > All I want to do is find the total elapsed time in hours,minutes and seconds > between them. > > I'm using the SUBDUR like this; > > EndTime SUBDUR StartTime Hour:*H > EndTime SUBDUR StartTime Minute:*MN > EndTime SUBDUR StartTime Second:*S > > Hour,Minute and second are part of a 6,0 data structure. When I put my > program in debug my 'elapsed' variable contains 010227. I suspect its > because of negatives I'm getting the minutes and seconds the way I am. > > What am I missing here? (Should I be doing this differently then SUBDUR?) > > Andy > > > > > > > > > > > _______________________________________________ > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@xxxxxxxxxxxx > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/mailman/listinfo/rpg400-l > or email: RPG400-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l. > > _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
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.