CharToSeconds Function
Description
Converts a time string to a number of seconds.
Syntax
CharToSeconds(timestring)
Arguments
timestring is a string that represents the time of day, in one of the following formats:
Format |
12 hour clock |
24-hour clock |
Military clock |
h:mm tt |
2:04 AM |
2:04 |
204 |
h:mm:ss tt |
2:04:58 AM |
2:04:58 |
20458 |
h:mm:ss.000 tt |
2:04:58.125 AM |
2:04:58.125 |
20458.125 |
hh:mm tt |
02:04 AM |
02:04 |
0204 |
hh:mm:ss tt |
02:04:58 AM |
02:04:58 |
020458 |
hh:mm:ss.000 tt |
02:04:58.125 AM |
02:04:58.125 |
020458.125 |
If the format contains an AM or PM, the hour is based on the 12-hour clock, where "AM," "am," "A," or "a" indicates times from midnight until noon, and "PM," "pm," "P," or "p" indicates times from noon until midnight. Otherwise, the hour is based on the 24-hour clock.
Return value
This function returns a number representing the number of seconds since 12:00 AM. If the time string cannot be successfully parsed, a null value is returned.
Calculated field example
If the Start_time field contained the string 12:10:45AM, and the End_time field contained the string 12:30:00AM, the following calculated field expression would return the number 1155, representing a duration of 19 minutes and 15 seconds: CharToSeconds(End_time)-CharToSeconds(Start_time)
Filter/Find example
Records with a duration of less than 1 minute can be selected or found using the expression: CharToSeconds(End_time)-CharToSeconds(Start_time)<60