FormatDateTime(Date, NamedFormat)

Date is the date expression to be formatted. NamedFormat is an optional constant that specifies how the date is formatted.

Const vbGen­er­al­Date = 0
Const vbLong­Date = 1
Const vbShort­Date = 2
Const vbLong­Time = 3
Const vbShort­Time = 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, vbLong­Date) & vbCrLf
	strResult = strResult & "Short Format Date is: " & FormatDateTime(strDate, vbShort­Date) & vbCrLf
	strResult = strResult & "Long Format Time is: " & FormatDateTime(strDate, vbLong­Time) & vbCrLf
	strResult = strResult & "Short Format Time is: " & FormatDateTime(strDate, vbShort­Time) & vbCrLf
	
	MsgBox strResult
End Sub

 

IDEAScript Language: