Tommy,

Part 2, turning the about calculation into your very own user-defined
function through a Stored Procedure:

Create a new file in the R:BASE Editor, named HHMM.pro

Copy the text between the lines of hyphens into your new document:

------------------------------------------------------------------------------------
CLEAR VAR RBTI_Return
SET VAR pvReturnTEXT TEXT = NULL

SET VAR pvReturnText = +
  ( +
  CTXT(INT(.pvIntegerParm / 3600 )) + ':' + +
   TRIM(FORMAT((NINT((MOD(.pvIntegerParm,3600)/60))),'00')) +
  )

RETURN .pvReturnTEXT
------------------------------------------------------------------------------------
Then type (or paste) this command at the R> prompt, all on one line:

PUT HHMM.pro AS HHMM pvIntegerParm INTEGER RETURN TEXT 'From integer
seconds input, returns string in form HH:MM'

If those two things work, you will have a stored procedure that takes your
"seconds" as a parameter, and returns your string. You can use this
procedure with the CALL function or the CALL command anywhere: in a report,
in a SELECT command, in a VIEW:

SET VAR vHHMMString = (CALL HHMM(139920))

Bill


On Tue, May 7, 2013 at 2:51 PM, Bill Downall <[email protected]
> wrote:

> Hi, Tommy!
>
> SET VAR vHours INT = (INT(133920/3600)) -- gives you hours (3600 seconds
> in an hour)
> SET VAR vSecsLeft INT = (MOD(133920,3600)) -- gives you left over seconds
> after you got the hours.
> SET VAR vMins INT = (INT(.vSecsLeft/60)) -- gives you truncated minutes,
> or
> SET VAR vMins INT = (NINT(.vSecsLeft/60)) -- gives you rounded minutes
>
> To create a string of the whole thing as a single expression (I got 37
> hours 12 minutes from your example, not 13 minutes),
>
> SET VAR vHHMMString = +
>   ( +
>   CTXT(INT(.vTotalSeconds / 3600 )) + ':' + +
>   TRIM(FORMAT((NINT((MOD(.vTotalSeconds,3600)/60))),'00')) +
>   )
>
> The FORMAT makes sure that if it is fewer than 10 minutes, it comes out as
> 37:09, not 37:9
> The TRIM gets rid of a space at the front of the minutes string, left by
> the FORMAT function
>
> Bill
>
>
> On Tue, May 7, 2013 at 2:23 PM, Tommy Croker <[email protected]> wrote:
>
>>
>>
>> Is there a function that I can enter 133920 seconds and have the output
>> be 37:13 for 37 hours and 13 minutes?  The RTime function seems to only
>> work on 24 hour basis.
>>
>>
>> Thanks
>>
>
>

Reply via email to