FormatDateTime(Date, NamedFormat)
Brian Element
Date is the date expression to be formatted. NamedFormat is an optional constant that specifies how the date is formatted.
Const vbGeneralDate = 0
Const vbLongDate = 1
Const vbShortDate = 2
Const vbLongTime = 3
Const vbShortTime = 4
Dim vbCrLf As String
Sub Main
Dim strDate
Dim strResult
vbCrLf = Chr(13) & Chr(10)
strDate = Now
strResult = "General Format Date is: " & FormatDateTime(strDate) & vbCrLf
strResult = strResult & "Long Format Date is: " & FormatDateTime(strDate, vbLongDate) & vbCrLf
strResult = strResult & "Short Format Date is: " & FormatDateTime(strDate, vbShortDate) & vbCrLf
strResult = strResult & "Long Format Time is: " & FormatDateTime(strDate, vbLongTime) & vbCrLf
strResult = strResult & "Short Format Time is: " & FormatDateTime(strDate, vbShortTime) & vbCrLf
MsgBox strResult
End Sub