Question: I have various formats of dates, in strings, all in ColumnA. Here is a small example.

```
-rw-r--r--   35 30067    10224     <-- 2018-09
-rw-r--r--   36 30067    10224     <-- 2018-09
-rw-r--r--   65 30067    10224     <-- 2018-10-24

```

Is there a way I can interpret any date from any given string?

Answer: 
I tried to get date with regular expression. As far as I see, the date is either in the end of the string or there's a dot after it (followed by extension). The regex takes into account the length of the year: either 4 or 2. Also it manages the case when month is expressed in text. *Important!* When the day is absent, I set it as first day.

```
Function GetDate(strString$)
    Dim sYear$, sMonth$, sDay$
    With CreateObject("VBScript.RegExp")
        .IgnoreCase = True: .Pattern = "(\d{2})([a-z]{3}|\d{2})(\d{2})?(?=\.|$)"
        With .Execute(strString)
            If .Count > 0 Then
                With .Item(0)
                    sYear = .SubMatches(0)
                    sMonth = .SubMatches(1)
                    sDay = .SubMatches(2)
                    sYear = "20" & sYear
                    If Not IsNumeric(sMonth) Then
                        sMonth = GetMonthIndex(sMonth)
                    End If
                    If Len(sDay) = 0 Then sDay = "01"
                    GetDate = DateSerial(CInt(sYear), CInt(sMonth), CInt(sDay))
                End With
            End If
        End With
    End With
End Function

Private Function GetMonthIndex$(strMonth$)
    Select Case strMonth
        Case "Jan": GetMonthIndex = "01"
        Case "Feb": GetMonthIndex = "02"
        Case "Mar": GetMonthIndex = "03"
        Case "Apr": GetMonthIndex = "04"
        Case "May": GetMonthIndex = "05"
        Case "Jun": GetMonthIndex = "06"
        Case "Jul": GetMonthIndex = "07"
        Case "Aug": GetMonthIndex = "08"
        Case "Sep": GetMonthIndex = "09"
        Case "Nov": GetMonthIndex = "10"
        Case "Oct": GetMonthIndex = "11"
        Case "Dec": GetMonthIndex = "12"
    End Select
End Function

```
Try

```
Sub test()
    Dim rngDB As Range
    Dim vDB As Variant, vR() As Variant
    Dim vS As Variant
    Dim i As Long, j As Integer, c As Integer
    Dim s As String

    Set rngDB = Range("a1", Range("a" & Rows.Count).End(xlUp))
    vDB = rngDB

    r = UBound(vDB, 1)
    ReDim vR(1 To r, 1 To 1)

    For i = 1 To r
        s = vDB(i, 1)
        vS = Split(s, ".")
        If IsNumeric(vS(1)) Then
            s = vS(1)
            s = Right(s, 6)
            s = Left(s, 2) & " " & Mid(s, 3, 2) & " " & Right(s, 2)
            vR(i, 1) = DateValue(s)
        Else
            s = vS(0)
            s = Right(s, 6)
            If IsNumeric(s) Then
                s = Left(s, 2) & " " & Mid(s, 3, 2) & " " & Right(s, 2)
                vR(i, 1) = DateValue(s)
            Else
                s = Right(s, 4)
                If IsNumeric(s) Then
                    s = Left(s, 2) & " " & Mid(s, 3, 2) & " " & 1
                    vR(i, 1) = DateValue(s)
                Else
                    s = vS(0)
                    s = Right(s, 7)
                    s = Left(s, 2) & " " & Mid(s, 3, 3) & " " & Right(s, 2)
                    vR(i, 1) = DateValue(s)
                End If
            End If
        End If
    Next i
    Range("b1").Resize(r) = vR

End Sub

```