Doug: There. There's the "too simple" I was missing. When jiggered just a tad:

CLS
SET VAR vTime_End TIME = 18:15
SET VAR vTime_Beg TIME = 07:45
SET VAR vTime_Elapsed DOUBLE = ( (.vTime_End - .vTime_Beg)/3600 )
WRITE .vTime_Elapsed
RETURN

Perfect. Thank you for your pack-R:at habits, and gratitude to Emmitt, for the gift he left behind.

Best, Bruce

------ Original Message ------
From: "Doug Hamilton" <[email protected]>
To: [email protected]
Sent: 7/14/2020 5:01:23 PM
Subject: Re: [RBASE-L] - Converting TIME Value to REAL Value

Bruce, This might be a start for elapsed time calcs. It's from my notes of January 2016, with credit to Emmitt Dove:

Finding total hours between 2 times
Assuming you have datetime values:
SET VAR vhours INTEGER = (INT((.vstoptime - .vstarttime) / 3600))
When you subtract two datetime values the result is the difference in seconds.
Emmitt Dove, 5/24/2007
###
--Elapsed Hr:Mn for integer # of minutes
R>SET VAR vMinutes INTEGER = 80
R>SET VAR vElapsed TEXT = (CTXT(INT(.vMinutes/60)) +':'+ CTXT(MOD(.vMinutes,60)))
R>show var vElapsed
1:20

Doug

On 7/14/2020 6:41 PM, Bruce Chitiea wrote:
I've been hunting for a simple function to convert a TIME value (e.g. 10:15) to a REAL value (e.g. 10.25), to make "elapsed time math" easy.

Something like: (DTIME(.vTimeValue)) ... which I'm not seeing.

This would reduce elapsed-TIME calculations to:

SET VAR vTime_End_DOUBLE = (DTIME(.vTime_End_TIME))
SET VAR vTime_Beg_DOUBLE = (DTIME(.vTime_Beg_TIME))
SET VAR vTime_Elapsed_DOUBLE = (.vTime_End_DOUBLE - .vTime_Beg_DOUBLE)

I'm absolutely sure I'm just missing something insanely simple. Meanwhile, something like Footnote [1] does the job, but forget about putting it in a Calculated Column Definition, which is the best place for such a basic calculation.

??

Thanks, Bruce

Bruce A. Chitiea
SafeSectors, Inc.
-----------------------------------
112 Harvard Ave #272
Claremont CA 91711-4716
-----------------------------------
[email protected]
-----------------------------------
+011 (909) 238-9012 c
+011 (909) 912-8678 f

[1] Not elegant, but it works:

SET VAR vTime_Beg TIME = NULL
SET VAR vTime_End TIME = NULL
SET VAR vTime_Elapsed DOUBLE = NULL

SET VAR vTime_Beg_IHR INT = NULL
SET VAR vTime_Beg_IMIN INT = NULL
SET VAR vTime_Beg_DMIN DOUBLE = NULL

SET VAR vTime_End_IHR INT = NULL
SET VAR vTime_End_IMIN INT = NULL
SET VAR vTime_End_DMIN DOUBLE = NULL

SET VAR vTime_End = 13:30
SET VAR vTime_Beg = 10:15

SET VAR vTime_Beg_IHR = (IHR(.vTime_Beg))
SET VAR vTime_Beg_IMIN = (IMIN(.vTime_Beg))
SET VAR vTime_Beg_DMIN = (.vTime_Beg_IMIN/60)

SET VAR vTime_End_IHR = (IHR(.vTime_End))
SET VAR vTime_End_IMIN = (IMIN(.vTime_End))
SET VAR vTime_End_DMIN = (.vTime_End_IMIN/60)

SET VAR vTime_Beg_DEC = (.vTime_Beg_IHR + .vTime_Beg_DMIN)
SET VAR vTime_End_DEC = (.vTime_End_IHR + .vTime_End_DMIN)
SET VAR vTime_Elapsed = (.vTime_End_DEC - .vTime_Beg_DEC)

WRITE .vTime_Beg_IHR
WRITE .vTime_Beg_IMIN
WRITE .vTime_Beg_DMIN
WRITE .vTime_Beg_DEC
WRITE ' '
WRITE .vTime_End_IHR
WRITE .vTime_End_IMIN
WRITE .vTime_End_DMIN
WRITE .vTime_End_DEC
WRITE ' '
WRITE .vTime_Elapsed

RETURN

--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/emd7e644de-7035-4588-b4ef-1d6053f7916b%40pathfinder <https://groups.google.com/d/msgid/rbase-l/emd7e644de-7035-4588-b4ef-1d6053f7916b%40pathfinder?utm_medium=email&utm_source=footer>.



--------------------------------------------------------------------------------
Avast logo
<https://www.avast.com/antivirus>
This email has been checked for viruses by Avast antivirus software.
www.avast.com <https://www.avast.com/antivirus>


<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/ae5fc457-1cc7-a2fd-e8ad-0b70b704152b%40wi.rr.com <https://groups.google.com/d/msgid/rbase-l/ae5fc457-1cc7-a2fd-e8ad-0b70b704152b%40wi.rr.com?utm_medium=email&utm_source=footer>.

--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/emdfb884d0-679f-4f32-a65d-d352b9daa413%40pathfinder.

Reply via email to