As ROSt52’s tests show, the user-defined cell format “DD MMM, YYYY HH:MM:SS” can be employed to show a date/time entered in another format, or the result of a calculation involving dates/times. But, unlike predefined formats, when a date/time is entered in a cell in this format, it is not interpreted as such by Calc, and so formulas referencing it will fail. The only workaround I could think of was a function to convert the date/time to one of the predefined formats:
Function ADATE(nadate)
'Function ADATE converts from “DD MMM, YYYY HH:MM:SS” to “MM/DD/YYYY HH:MM:SS”.
nadate = Trim(nadate)
ADATE = MM(Mid(nadate,4,3)) & "/" & Left(nadate,2) & "/" & _
Mid(nadate,9,4) & " " & Right(nadate,8)
End Function
Function MM(MMM)
'The output of auxiliary function MM is a string of the two-digit numerical month code.
Select Case MMM
Case "Jan"
MM = "01"
Case "Feb"
MM = "02"
Case "Mar"
MM = "03"
Case "Apr"
MM = "04"
Case "May"
MM = "05"
Case "Jun"
MM = "06"
Case "Jul"
MM = "07"
Case "Aug"
MM = "08"
Case "Sep"
MM = "09"
Case "Oct"
MM = "10"
Case "Nov"
MM = "11"
Case "Dec"
MM = "12"
End Select
End Function
The screenshot below shows function ADATE in action:
Cell C2 contains a date/time in “DD MMM, YYYY HH:MM:SS” format. Cell D2 has the formula “=ADATE(C2)” that converts the contents of C2 to “MM/DD/YYYY HH:MM:SS”. In cell E2 the formula “=D2+1” yields the expected result. Notice also that cell E2 has the user-defined format “DD MMM, YYYY HH:MM:SS”, which in this case works because it operates on the results of a formula evaluation.