Here's an attempt to emulate the date-related portion of Visual Basic's Format function. I did not need the time-related functionality, but it could be added easily
Public Function FormatDate(ByVal sDate, ByVal sFormat)
If Not IsDate(sDate) Then
FormatDate = "Invalid date"
Exit Function
End If
'Set the possible date-related values
d = Day(sDate)
dd = Right("0" & Day(sDate), 2)
DDD = WeekdayName(Weekday(sDate), True)
DDDD = WeekdayName(Weekday(sDate))
m = Month(sDate)
mm = Right("0" & Month(sDate), 2)
MMM = MonthName(Month(sDate), True)
MMMM = MonthName(Month(sDate))
cc = Left(Year(sDate), 2) 'century
yy = Right(Year(sDate), 2)
yyyy = Year(sDate)
sTempDate = sFormat
'Replace formatting with actual values
'Used case sensative search & replace due to long names
If InStr(1, sTempDate, "yyyy", 0) > 0 Then sTempDate = Replace(sTempDate, "yyyy", yyyy)
If InStr(1, sTempDate, "yy", 0) > 0 Then sTempDate = Replace(sTempDate, "yy", yy)
If InStr(1, sTempDate, "dd", 0) > 0 Then sTempDate = Replace(sTempDate, "dd", dd)
If InStr(1, sTempDate, "d", 0) > 0 Then sTempDate = Replace(sTempDate, "d", d)
If InStr(1, sTempDate, "mm", 0) > 0 Then sTempDate = Replace(sTempDate, "mm", mm)
If InStr(1, sTempDate, "m", 0) > 0 Then sTempDate = Replace(sTempDate, "m", m)
'The long names must come last because the search & replace above will
'incorrectly replace the values in the names
If InStr(1, sTempDate, "DDDD", 0) > 0 Then sTempDate = Replace(sTempDate, "DDDD", DDDD)
If InStr(1, sTempDate, "DDD", 0) > 0 Then sTempDate = Replace(sTempDate, "DDD", DDD)
If InStr(1, sTempDate, "MMMM", 0) > 0 Then sTempDate = Replace(sTempDate, "MMMM", MMMM)
If InStr(1, sTempDate, "MMM", 0) > 0 Then sTempDate = Replace(sTempDate, "MMM", MMM)
FormatDate = sTempDate
End Function