|--------------First Function--------------|
Function ConvertDate(TwoDay As String) As String
If Len(TwoDay) = 9 Or Len(TwoDay) = 8 Then
bigStr$ = TwoDay
littleStr$ = "/"
positionOfChar& = Instr(1, bigStr$, littleStr$)
'Get the day of the month part of the date
If positionOfChar& = 2 Then 'Single digit day of the month
subString = "0" + Left$(bigStr$, 1)
Elseif positionOfChar& = 3 Then 'Double digit day of the month
subString = Left$(bigStr$, 2)
End If
'Get the month part of the date
If positionOfChar& = 2 Then 'Single digit day of the month
subStringx = Mid$(bigStr$, 3, 2)
If Isnumeric(subStringx) Then 'Month is a double digit number
ConvertDate = subString + "/" + subStringx + "/" + Right$(bigStr$, 4)
Else 'Month is not a double digit number
ConvertDate = subString + "/" + "0" + Mid$(bigStr$, 3, 1) + "/" + Right$(bigStr$, 4)
End If
Elseif positionOfChar& = 3 Then 'Double digit day of the month
subStringx = Mid$(bigStr$, 4, 2)
If Isnumeric(subStringx) Then 'Month is a double digit number
ConvertDate = subString + "/" + subStringx + "/" + Right$(bigStr$, 4)
Else 'Month is not a double digit number
ConvertDate = subString + "/" + "0" + Mid$(bigStr$, 4, 1) + "/" + Right$(bigStr$, 4)
End If
End If
Else
ConvertDate = TwoDay
End If
End Function
|--------------Second Function--------------|
Function ConvertDateUS( ) As String
bigStr$ = Cstr(Today())
littleStr$ = "/"
positionOfChar& = Instr(1, bigStr$, littleStr$)
'Get the month part of the date
If positionOfChar& = 2 Then 'Single digit month
subString = "0" + Left$(bigStr$, 1)
Elseif positionOfChar& = 3 Then 'Double digit month
subString = Left$(bigStr$, 2)
End If
'Get the day of the month part of the date
If positionOfChar& = 2 Then 'Single digit month
subStringx = Mid$(bigStr$, 3, 2)
If Isnumeric(subStringx) Then 'Day of the month is a double digit number
ConvertDateUS = subStringx + "/" + subString + "/" + Right$(bigStr$, 4)
Else 'Day of the month is not a double digit number
ConvertDateUS = "0" + Mid$(bigStr$, 3, 1) + "/" + subString + "/" + Right$(bigStr$, 4)
End If
Elseif positionOfChar& = 3 Then 'Double digit month
subStringx = Mid$(bigStr$, 4, 2)
If Isnumeric(subStringx) Then 'Day of the month is a double digit number
ConvertDateUS = subStringx + "/" + subString + "/" + Right$(bigStr$, 4)
Else 'Day of the month is not a double digit number
ConvertDateUS = "0" + Mid$(bigStr$, 4, 1) + "/" + subString + "/" + Right$(bigStr$, 4)
End If
End If
End Function