Elegant, simple, and, as you say, covers the world. Helps quite a lot.

Very much appreciated, Bruce

------ Original Message ------
From: javier.valen...@vtgonline.com
To: rbase-l@googlegroups.com
Sent: 7/14/2020 5:19:54 PM
Subject: RE: [RBASE-L] - Converting TIME Value to REAL Value

You can use the DATETIME type and it will do the math for you:

R>SET VAR vStart DATETIME = '07/14/2020 19:06:36'


R>SET VAR vEnd DATETIME = '07/16/2020 19:06:36'


R>SET VAR vElapsed = .vEnd - vStart


R>show var vStart

07/14/2020 19:06:36


R>show var vEnd

07/16/2020 19:06:36


R>show var vElapsed

     172800



Which is the elapsed time in seconds that you can easily converts to days, hours, minutes and seconds as needed. This will also count for days, months and years so you will not have to worry when the elapsed time spans days or months or years.



Javier,



Javier Valencia, PE

14315 S. Twilight Ln.

Olathe, KS 66062

Office: 913-829-0888

Cell: 913-915-3137



From:rbase-l@googlegroups.com [mailto:rbase-l@googlegroups.com] On Behalf Of Bruce Chitiea
Sent: Tuesday, July 14, 2020 6:41 PM
To:rbase-l@googlegroups.com
Subject: [RBASE-L] - Converting TIME Value to REAL Value



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

-----------------------------------

rby...@safesectors.com

-----------------------------------

+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 rbase-l+unsubscr...@googlegroups.com. 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>.


--
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 rbase-l+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/!%26!AAAAAAAAAAAYAAAAAAAAAO1ueGVb5zRMiwo7hebUe7jCgAAAEAAAAFJ0zfUKNqxKtgZZ6E0ql5IBAAAAAA%3D%3D%40vtgonline.com <https://groups.google.com/d/msgid/rbase-l/!%26!AAAAAAAAAAAYAAAAAAAAAO1ueGVb5zRMiwo7hebUe7jCgAAAEAAAAFJ0zfUKNqxKtgZZ6E0ql5IBAAAAAA%3D%3D%40vtgonline.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 rbase-l+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/em030b928c-bf47-4db5-a3ce-1fbc8f7b7788%40pathfinder.

Reply via email to