Access: TimeValue Function

In Access, the TimeValue function returns the time represented by a string argument.

The syntax for the TimeValue function is:

TimeValue ( string )

The required string argument is normally a string expression representing a time from 0:00:00 to 23:59:59,  inclusive. You can enter valid times using a 12- or 24-hour clock. If time contains Null, Null is returned. If string includes date information, TimeValue does not return it. However, if string includes valid date information, an error occurs.

Examples

TimeValue ("27/11/2005 4:47:31 AM")     returns '4:47:31 AM' 
TimeValue ("4:47:31 AM")                       returns '4:47:31 AM'
TimeValue ("17:22:43")                          returns '5:22:43 PM'

VBA Code

Dim MyTime As String 
MyTime = TimeValue("10:35:54 PM")

This example uses the TimeValue function to convert a string to a time. Now the MyTime variable would contain the value of ’10:34:54 PM’.

SQL query

You can also use the TimeValue function in a query.

SELECT TimeValue('12:45:37') AS Expr1 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.