A forward slash char in a string is transformed into a DATE in excel if exported as CSV or COPY.

A forward slash char in a string is transformed into a DATE in excel if exported as CSV or COPY.

chsxechsxe Posts: 8Questions: 3Answers: 0

I have column that concatenates 2 values that are separated by a forward slash. The data is shown like this (1/25). When I export the data to CSV or COPY, excel reads this as a date (25-Jan). this only happens if the values are small enough to be a date. Is there a solution to stopping excel reading this as a date.

CSV Export Expected Result: 1/25
CSV Export Actual Result: Jan-25

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @chsxe ,

    CSV file don't contain any formatting, purely the strings separated by columns. If you look at this example here, and open the file in gedit/emacs/vi/etc., you'll see the cell does contain "1/25" as expected. It's only being changed when you load up Excel - as it tries to 'helpfully' interpret the type of the cell, but you can then format the cell in Excel as tell it to treat it as a string.

    Cheers,

    Colin

  • chsxechsxe Posts: 8Questions: 3Answers: 0

    Hi @colin,

    Thanks for your reply, I was hoping there was a way to format the data upon exporting to CSV that would change how excel interpreted the data. I'll just have to format the data before it is displayed in the column.

    Cheers,
    CH

This discussion has been closed.