Hey guys on a 24-hour clock, that is correct, there are 20 hours between
2 am and 10 pm and only 4 between 10 pm and 2 am for a total of 24 hours
in the day... ~Claudine :)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:owner-rbase-l@;sonetmail.com]
On Behalf Of randyp
Sent: Thursday, October 17, 2002 3:47 PM
To: [EMAIL PROTECTED]
Subject: Re: Date and Time differences - crossing midnight

Dear Mike,

        I can see how the calculation may be arithmetically
accurate.  But
it seems to me to be of limited practical use.

        If I take the time of day and cross midnight, the
result does not
make sense to me using the 'difference between two time
values' method.

        A time difference of -72000 seconds is saying that
there is a 20 hour
negative difference in the time.  If you were comparing 2:00
am on one
day to 22:00 the same day, the difference would be 72000
seconds or
20 hours.

        But the difference in time between 10:00 pm and 2:00
am is 4 hours.

So you would have to use an expression to accommodate
negative time:
 (IFLT(.timeDiff,0, (86400 + .timeDiff), .timeDiff))
if you want the result to be meaningful even for a period
less than
24 hours.  [24 hours * 3600 seconds = 86,400 seconds]

--TimeTest.rmd
SET VAR v1 DATETIME = '08/09/95 22:15:30.123';
SET VAR v2 DATETIME = '08/10/95 2:15:30.123';
SET VAR v3 INTEGER = ((TEXTRACT(.v2)) - (TEXTRACT(.v1)));
show var v3  *(= -72000)

SET VAR v1 DATETIME = '08/09/95 22:15:30.123';
SET VAR v2 DATETIME = '08/11/95 2:15:30.123';
SET VAR v3 INTEGER = ((TEXTRACT(.v2)) - (TEXTRACT(.v1)));
show var v3  *(= -72000)

SET VAR v1 DATETIME = '08/09/95 22:15:30.123';
SET VAR v2 DATETIME = '08/12/95 2:15:30.123';
SET VAR v3 INTEGER = ((TEXTRACT(.v2)) - (TEXTRACT(.v1)));
show var v3 *(= -72000)

---
SET VAR fvtrEnteredDt DATETIME = '08/9/95 22:15:30.123'
SET VAR fvtrAssignToDt DATETIME = '08/10/95 2:15:30.123'
SET VAR dtDiff = ( .fvtrAssignToDT-.fvtrEnteredDT )

SET VAR fvtrDispTime = +
( (FORMAT( (IFGT( (.DTdiff), 86400,(INT( (.DTdiff) /3600)),
+
(IHR( (RTIME(0,0, (.DTdiff) )) )) )), '99,900' )) +
+ ':' + (FORMAT( (IMIN( (RTIME(0,0,.DTdiff)) )),'00')) )
SHOW VAR fvtrDispTime *(= 04: 00)

---

SET VAR fvtrEnteredDt DATETIME = '08/9/95 22:15:30.123'
SET VAR fvtrAssignToDt DATETIME = '08/11/95 2:15:30.123'
SET VAR dtDiff = ( .fvtrAssignToDT-.fvtrEnteredDT )

SET VAR fvtrDispTime = +
( (FORMAT( (IFGT( (.DTdiff), 86400,(INT( (.DTdiff) /3600)),
+
(IHR( (RTIME(0,0, (.DTdiff) )) )) )), '99,900' )) +
+ ':' + (FORMAT( (IMIN( (RTIME(0,0,.DTdiff)) )),'00')) )
SHOW VAR fvtrDispTime *(= 28:00)

---

SET VAR fvtrEnteredDt DATETIME = '08/9/95 22:15:30.123'
SET VAR fvtrAssignToDt DATETIME = '08/12/95 2:15:30.123'
SET VAR dtDiff = ( .fvtrAssignToDT-.fvtrEnteredDT )

SET VAR fvtrDispTime = +
( (FORMAT( (IFGT( (.DTdiff), 86400,(INT( (.DTdiff) /3600)),
+
(IHR( (RTIME(0,0, (.DTdiff) )) )) )), '99,900' )) +
+ ':' + (FORMAT( (IMIN( (RTIME(0,0,.DTdiff)) )),'00')) )
SHOW VAR fvtrDispTime *(= 52: 00)

Best regards,

        Randy Peterson


----- Original Message -----
From: "Mike Willochell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 17, 2002 3:36 PM
Subject: Re: Date and Time differences


> At 02:31 PM 10/17/2002 -0400, you wrote:
> >Dear Mike
> >
> >SET VAR vElapsed = (RTIME(0,0,.v3)) will return the
> >erroneous result 1:0:0. It is erroneous because it
suggests
> >that only one hour has elapsed even though for the second
> >and third instances, the elapsed time should be 25:0:0
and
> >49:0:0 respectively.
>
> Dear Randy;
>
> Expanding on my last post, RTIME actually does not return
an
> erroneous result in this demonstration because 3600 is the
difference
> between the two TIME values (remember, we neglected the
DATE
> information using the TEXTRACT function).
>
> However, if you use Bill's example, and you plug a value
like 90000
> seconds (25 hours * 3600 seconds in an hour) you will see
that
> RTIME returns 1:0:0. The reason for this is that RTIME
uses your
> R:BASE TIME settings. The time in a day never goes beyond
23:59:59
> so whenever you exceed 86399 seconds, RTIME returns 1:0:0.
This is
> expected behavior.
>
> I hope this didn't get too confusing.
>
> Best Regards,
>
> Mike



================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/

================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/

Reply via email to