Format

Public Function Format(ByVal Expression As Variant, ByVal Format As String) As String

Formats a numeric or date value with a formatting pattern.

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

Public Function GetDateTimeForExportFile(pDate As Date) As String
   Return Format(pDate, "yyyy-MM-dd HH:mm:ss")
End Function

See also: