VBA Retrieve time from date

Опубликовано: 12 Февраль 2026
на канале: Simplified Excellence
17
0

Get the time from a date, i.e. extract the time only.

Code:
Sub retrieve_time_from_date()

Dim myDate As Date
Dim extracted_time As Date

'current date and time
myDate = Now

'display
MsgBox ("This is: " & myDate)

'retrieve the time
extracted_time = FormatDateTime(myDate, vbShortTime)

'display time
MsgBox ("Here is the time: " & extracted_time)

End Sub

-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.

-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!