Forum Discussion

Alex70's avatar
Alex70
Copper Contributor
Aug 25, 2025

How to convert dates in excel to common format.

Good day. Please support - I have 2 dates generated from SAP and which come in different formats (columns E & G). 

I have already tried all possibilities to change it via built-in excel settings, but no positive result. 

Please advise if there are any options to adjust dates format to common. Note* date in column G to be read as January 2, not Feb. 1.   

 

 

 

4 Replies

  • OlufemiO's avatar
    OlufemiO
    Brass Contributor

    Hi Alex70​

    SAP exports often produce dates in mixed formats, which can make Excel misinterpret day and month. Here is a solution to standardize your columns E and G (and any other SAP date columns) so Column G is read as January 2, not February 1.

    Step 1: Check if the dates are text or real Excel dates

    Use:

    excel

    =ISNUMBER(E2)

    =ISNUMBER(G2)

    If the result is TRUE, Excel already recognizes it as a date. If FALSE, it’s text and needs conversion.

     

    Step 2: Use Excel 365 formula to convert text dates

    In a helper column:

    excel

    =IF(ISNUMBER(E2), E2,

      LET(

        raw, TRIM(E2),

        s, SUBSTITUTE(SUBSTITUTE(raw, ".", "/"), "-", "/"),

        pos1, FIND("/", s),

        pos2, FIND("/", s, pos1+1),

        d, VALUE(LEFT(s, pos1-1)),

        m, VALUE(MID(s, pos1+1, pos2-pos1-1)),

        y, VALUE(RIGHT(s, LEN(s)-pos2)),

        DATE(y, m, d)

      )

    )

    This works for DD.MM.YYYY, DD/MM/YYYY, and forces day/month/year order. Repeat for Column G if needed.

     

    Step 3: Format the result

    Select Columns E and G → Right-click → Format Cells → Custom → Enter:

    Code

    DD-MMM-YYYY

    Example: 02-Jan-2025

     

    Step 4: Automate with VBA (for future SAP imports)

    vba

    Sub StandardizeAllSAPDates()

        Dim ws As Worksheet, cell As Range, col As Range

        Dim parts() As String, d As Long, m As Long, y As Long

        Set ws = ActiveSheet

     

        For Each col In ws.UsedRange.Columns

            For Each cell In col.Cells

                If Not IsEmpty(cell.Value) Then

                    If Not IsDate(cell.Value) Then

                        cell.Value = Replace(Replace(cell.Value, ".", "/"), "-", "/")

                        parts = Split(cell.Value, "/")

                        If UBound(parts) = 2 Then

                            d = CLng(parts(0))

                            m = CLng(parts(1))

                            y = CLng(parts(2))

                            cell.Value = DateSerial(y, m, d)

                        End If

                    End If

                    cell.NumberFormat = "DD-MMM-YYYY"

                End If

            Next cell

        Next col

     

        MsgBox "All SAP dates standardized successfully!"

    End Sub

    Usage: Press ALT + F11 → Insert → Module → Paste the code → Run StandardizeAllSAPDates

     

    This ensures mixed text and serial dates are standardized, Column G is read correctly as January 2, and future imports can be fixed automatically.

  • The created on field appears to contain text.  It is human-readable but of no meaning for Excel.  Another possibility is to leave the text on the worksheet but to use the date in a formula you could start by converting it to a date

    = LET(
        createdDate, DATEVALUE(SUBSTITUTE(textDate,".","/")),
        createdDate
      )

    or, if you consider that shows too much irrelevant detail on the worksheet you could define a trivial Lambda function

    = DATEVALUEλ(textDate)
    
    where
    
    DATEVALUEλ = LAMBDA(textDate, 
        LET(
            createdDate, DATEVALUE(SUBSTITUTE(textDate,".","/")),
            createdDate
        )
    );

     

  • Select the dates in column G.

    On the Data tab of the ribbon, click Text to Columns.

    Select Delimited, then click Next > twice.

    In Step 3 of the Text to Columns wizard, select DMY from the Date drop-down.

    Click Finish.

    Apply the desired date format and adjust the column width, if necessary.

Resources