April 27, 2005, 04:22 PM
<Mirza>Hours and Seconds
Hello,
I was wondering if anyone knows of a technique or function to convert seconds to minutes:seconds.
For example, when a field contains 129 seconds, the output should produce 2:09.
Thanks in advance!
April 27, 2005, 05:57 PM
Francis MarianiIdeally, it would be done using the HHIS date-time format, which a Time only format, HH:MM:SS.
This example puts the current time in the HHIS field:
DEFINE FILE CAR
TIMEX/HHIS = HGETC(8,'HHIS')
END
TABLE FILE CAR
PRINT MODEL TIMEX
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF,
FONT='VERDANA', SIZE=8, $
ENDSTYLE
END
I absolutely cannot figure out how to get a numeric field that contains seconds into the HHIS field.
My solution:
DEFINE FILE CAR
SECONDS/I4 = 129;
TIME_MM/I2 = SECONDS / 60;
-* IMOD(DIVIDEND, DIVISOR, OUTFIELD)
TIME_SS/I2 = IMOD(SECONDS, 60,'I2') ;
TIME_MMSS/A5 = EDIT(TIME_MM) | ':' | EDIT(TIME_SS);
END
TABLE FILE CAR
PRINT MODEL SECONDS TIME_MM TIME_SS TIME_MMSS
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF,
FONT='VERDANA', SIZE=8, $
ENDSTYLE
END
April 27, 2005, 06:38 PM
PrarieJack Gross gave me this routine back in February
hhmmss/I6= INT( seconds/3600 ) * 10000 + INT( IMOD(seconds,3600,'I4')/60 ) * 100 + IMOD(seconds,60,'I2');time/A8=EDIT(hhmmss,'99:99:99');
April 28, 2005, 04:09 AM
susannahooooo. that's sweeeeeet. Thanks for sharing that, Prairie.