Time Function Returns a String Value
Returns the string representation for the numeric time value. If the time_value is less than 60,000, then it returns "12:00 AM". Refer to the MKTIME( ) function for the formula used.

Function Use

This function is typically used when formatting how times are displayed or returned. This function is not typically used when filtering records. Consider using the MKTIME( ) or TIMENUM( ) function for time-based filtering.

Formatting

You can use Optional Switches or Format Modifiers to determine how the time is displayed.

AM/PM Switch

The AM/PM switch determines whether AM/PM is printed or military time is used. Using no AM/PM switch or a value of 1 prints AM/PM (i.e., "4:30 PM"). Using a value of 0 for the AM/PM switch excludes AM/PM and prints using military time (i.e., "1630").

Seconds Switch

The seconds switch determines whether seconds are printed. Using no seconds switch or a value of 0 excludes the seconds. Using a value of 1 for the seconds switch prints the seconds using an hh:mm:ss format.

Additionally, format modifiers can be used to specify the format displayed for the time, including whether the time displays using a 12 or 24-hour format, has leading zeros, and how the am/pm indicator is displayed. Colons and additional text used in this function will be displayed in the output (e.g., "03:08:52" or "8 minutes after 3 PM"). Format modifiers must be enclosed in quotation marks and must come before the time_value. Format modifiers are case insensitive.

If the optional switches and format modifiers are not used, the time displays using the hh:mm AM format. If no time_value is specified, the current system time is used.

Note: Switches and format modifiers cannot be used together in the same function statement.

Format Modifiers:

Modifier Result Example Value if Empty1
%h hours with leading zeros in 12-hour notation 03:08 PM hh
%i hours without leading zeros in 12-hour notation 3:08 PM hh
%j hours with leading zeros in 24-hour notation 03:08 if AM, 15:08 if PM hh
%k hours without leading zeros in 24-hour notation 3:08 if AM, 15:08 if PM hh
%m minutes with leading zeros 03:08 PM mm
%n minutes without leading zeros 8 minutes after 3 PM mm
%s seconds with leading zeros 03:15:02 PM ss
%t seconds without leading zeros 3:15:2 PM ss
%a lower-case single-digit a/p indicator 03:15 p a
%b upper-case single-digit a/p indicator 03:15 P A
%c lower-case full am/pm indicator no periods 03:15 pm am
%d upper-case full am/pm indicator no periods 03:15 PM AM
%e lower-case full am/pm indicator with periods 03:15 p.m. a.m.
%f upper-case full am/pm indicator with periods 03:15 P.M. A.M.

 

1 When a specified date field is empty (e.g., Due Date,etc.), values will be represented by a placeholder for the field (e.g., if %h, then hh; if %t, then ss, etc.).

General Examples

TIME$( )

Returns "08:42 AM" if the current system time is 8:42 AM.

TIME$(49500000) 

Returns "01:45 AM".

Examples using Optional Switches

TIME$(MKTIME(15,35), 0)

Returns "15:35".

TIME$(MKTIME(15,35), 1)

Returns "03:35 PM".

TIME$(MKTIME(15,35), 1, 1)

Returns "03:35:00 PM".

TIME$(MKTIME(15,35), 0, 1)

Returns "15:35:00".

TIME$(MKTIME(15,35), 1, 0)

Returns "03:35 PM".

Examples using Format Modifiers

When using format modifiers, only the portion of the time that a modifier is entered for will be displayed. For example, if no modifier for the seconds is entered, the seconds will not be displayed.

TIME$("%h:%m %c") 

Returns "4:30 pm" if the current system time is 4:30 pm.

TIME$("%n minutes after %i %d")

Returns "30 minutes after 4 PM" if the current system time is 4:30 pm.

TIME$("%k:%n", MKTIME(15,35))

Returns "15:35".

TIME$("%h:%n %d", MKTIME(15,35))

Returns "03:35 PM".

TIME$(%h:%n:%s %e", MKTIME(15,35))

Returns "03:35:00 p.m.".

TIME$("%k:%n:%s", MKTIME(15,35))

Returns "15:35:00".

TIME$("%i:%m %f", MKTIME(15,35))

Returns "3:35 P.M.".

TIME$("%k%n", MKTIME(15,35)) 

Returns "1535".

Other Resources

 

See also:   NOW$( )