Here's the final version of the function
Function SpacedDate(aDateField)
'Purpose: Inserts spaces between the digits of dates with the numeric form
of ddmmyyyy
' Returns "d d m m y y y y" or "null date"
'Caution: No handling of months with more than 99 days
If Not (IsDate(aDateField)) Then
SpacedDate = "null date"
Else
'Does the inside Format() return a leading 0?
If Left(Format(aDateField, "ddmmyyyy"), 1) = 0 Then
'It does, so the outside Format() will substitute a leading space for
the leading 0
'so supply the expected leading zero for days 1 to 9
SpacedDate = "0" & Format(Format(aDateField, "ddmmyyyy"), "# # # # # # #
#")
Else
'days 10 to 28,29,30, or 31
SpacedDate = Format(Format(aDateField, "ddmmyyyy"), "# # # # # # # #")
End If
End If
End Function