TOTIME Function
Syntax
Arguments
- secondsNumeric
The number of seconds past midnight.
- format_codeNumeric
One of the following formats.
- Format Parameter Value
Format
- 0
ss
- 1
hh:mm
- 2
hh:mm:ss
- 3
ddd:hh:mm:ss
- 11
hh:mm AM/PM
- 12
hh:mm:ss AM/PM
- 13
ddd:hh:mm:ss AM/PM
- decimal_placesNumeric
The number of decimal places for seconds. The integer value can be from 0 to 3.
Returns
- Formatted_Short_TimeCharacter
Returns the formatted time value.
Description
Converts a time value to a formatted time character string.
Discussion
TOTIME() returns a formatted character string containing a time based on the specified number of seconds past midnight. The resulting formatted string can be in one of seven formats specified by the format code, and can contain up to three decimal places for seconds.
Example
? totime(125, 2, 0) = "0:02:05" ? totime(863.5, 12, 1) = "0:14:23.5 AM"
You may often need to compute an event's ending time, given the event's start time and duration. For example, assume that an event's start time is stored in START and the event duration (expressed as hh:mm) is stored in DURATION. You can use the following expression to return the time that the event ended:
totime((toseconds(START) + toseconds(DURATION), 1, 0)
If you have imported a time value from Microsoft Excel as a character or numeric value and you wish to convert it to a Short Time value, the following expressions will do the job.
dim dat as C dat = .345 ? totime((val(dat) * 86400),1,0) = "8:17" dim dat2 as N dat2 = .345 ? totime(dat2 * 86400,1,0) = "8:17"
See Also