Format
Public Function Format(ByVal Expression As Variant, ByVal Format As String) As String
Formats a numeric or date value with a formatting pattern.
- Expression: The value to format
- Format: The formatting expression.
For dates, you can use the following case sensitive (!) expressions. See also: https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings for dates and https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings for number.s
- yy: The year in 2 digits
- yyyy: The year in 4 digits
- M: The month in 1 or 2 digits
- MM: The month in 2 digits
- MMM: The short month name (English)
- MMMM: The full month name (English)
- d: The day in 1 or 2 digits
- dd: The day in 2 digits
- ddd: The short day name (English)
- dddd: The full day name (English)
- h: The hour in 1 or 2 digits in 12 hour notation.
- hh: The hour in 2 digits in 12 hour notation.
- H: The hour in 1 or 2 digits in 24 hour notation.
- HH: The hour in 2 digits in 24 hour notation.
- t / tt: The AM/PM indicator in 1 or 2 digits.
- m / mm: The minutes in 1 or 2 digits.
- s / ss: The seconds in 1 or 2 digits.
Public Function GetDateTimeForExportFile(pDate As Date) As String
Return Format(pDate, "yyyy-MM-dd HH:mm:ss")
End Function
See also: