<cTime> Designates a character string that contains the time in the format “HH:MM:SS:hh”. The default is the system time.
The returned value designates how many seconds have elapsed between midnight and <cTime>. Hundredths of seconds are contained as a decimal value.
When computing time periods, or when adding times, it is simpler to deal with seconds since midnight instead of time designations. These calculations are simplified significantly. The SECTOTIME() function converts the result into a time designation again. Starting from back to front, you can omit the hundredths, seconds, and minutes from the time string that is passed as a parameter. These values are then assumed to be “00”.
If you do not specify a parameter, the function uses the current time on the system clock.
. A simple conversion:
? TimeToSec("12:44:33:22") // Result: 45873.22
. The period between two times is calculated. The result is
displayed in seconds:
cBegin := "12:55:44:33"
cEnd := "14:56:12:22"
? TimeToSec(cEnd) - TIMETOSEC(cBegin) // Period in seconds
. Possible formats:
Converts seconds into a time string
SecToTime(<nSeconds>, [<lHundredth>]) --> cTimeArguments<nSeconds> Designates the number of seconds since midnight to
convert into a character string in time format.
<lHundredth> If this optional parameter is designated as .T., the
resulting time string contains hundredths of seconds. The default is no
SecToTime() returns a time string that corresponds to <nSeconds> in the
"HH:MM:SS" or "HH:MM:SS:hh" format.
This function can be applied in two areas -- to convert numeric time
spans in seconds, and to convert a point in time into the "HH:MM:SS" or
If hundredths of seconds are also desired in the time string result,
then designate the second parameter as .T.. The portion of the value
for <nSeconds> to the right of the decimal is also converted.
Notes. Seconds since midnight are in the range of 0 to 86400. With
larger values, the function internally executes the operation
% 86400 and then uses the result value. 86400 seconds corresponds to
an entire day.
. There is no rounding when values like 45366.98 are converted
Examples. Calculate the span between two times. The result is displayed
in the "HH:MM:SS" format:
nBeginning := 170
nEnd := 3656
? SECTOTIME(nEnd - nBeginning) // "00:58:06"
. With hundredth seconds:
? SECTOTIME(45873.22, .T.) // "12:44:33:22"
Introduction Date/Time FunctionsADDMONTH() Adds or subtracts months to/from a date
BOM() Determines the date of the first day of a month
BOQ() Determines the date for the beginning of a quarter
BOY() Determines the date for the beginning of a year
CTODOW() Converts the day of the week name into a corresponding number
CTOMONTH() Converts the name of the month into a corresponding number
DMY() Returns a date in "DD Month YY" format
DOY() Determines the day of the year for a specific date
EOM() Determines the date for the last day of a month
EOQ() Determines the date for the end of a quarter
EOY() Determines the date for the end of the year
ISLEAP() Tests if a specific year is a leap year
LASTDAYOM() Determines the number of days in a month
MDY() Returns a date in the "Month DD, YY" format
NTOCDOW() Changes the number of a weekday into a weekday name
NTOCMONTH() Changes the number of a month into a month name
QUARTER() Determines the quarter in which a specific date lies
SECTOTIME() Converts seconds into a time string
SETDATE() Sets the system date
SETTIME() Sets the system clock
SHOWTIME() Continuously displays the time at desired screen position
STOD() Converts an ANSI date string into Clipper format
TIMETOSEC() Calculates the seconds since midnight
TIMEVALID() Determines whether a specified time is valid
WAITPERIOD() Pauses a specified time in increments of 1/100 seconds
WEEK() Returns the calendar week for a date
WOM() Returns the week within a month.