MS Access TimeValue() Function

The TimeValue() function in MS Access converts a text string representing a time into an actual time value that MS Access can understand and use in calculations or comparisons.



TimeValue(): Definition and Usage

This function is extremely useful when you're working with time data stored as text (e.g., from an import) and need to convert it into a format suitable for time-related operations within MS Access.

Syntax

Syntax

TimeValue(string)
      

Parameter Values

Parameter Description
string A string containing a time value. The format should be recognizable by MS Access (e.g., "HH:MM:SS" or "HH:MM:SS AM/PM"). This is required.

Examples

Converting a 24-Hour Time String

This example converts a time string in 24-hour format to an MS Access time value.

Syntax

SELECT TimeValue("17:15:38");
      
Output

17:15:38  (Displayed as a time value in MS Access)
      

Converting a 12-Hour Time String

This example demonstrates converting a time string in 12-hour format (with AM/PM indicator).

Syntax

SELECT TimeValue("5:15:38 PM");
      
Output

17:15:38 (Displayed as a time value in MS Access)