+ Reply to Thread
Results 1 to 6 of 6

Excel to CSV - Date format with wrong output

  1. #1
    Registered User
    Join Date
    04-22-2019
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    24

    Excel to CSV - Date format with wrong output

    Dear all,

    I have created an excel which transform my xls file into a csv according with header needs.
    One of the values that I need to export on my CSV is the date which on my xls file is DD/MM/YYYY, but when I export it for an CSV file it become MM/DD/YYYY

    below the line where I export the date into the CSV file:

    cs.Range("E2") = bs.Range("D8").Value 'Date
    so basically I'm directly passing the value of my D8 cell into the E2 destination CSV file.

    I tried to change .Value to .Text(date, "DD/MM/YYYY"), but I have a mismatch error.

    Any tips to overcome this issue?

    Thank you in advance,

  2. #2
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Excel to CSV - Date format with wrong output

    Hi, how about below or after above statement:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    Last edited by Eastw00d; 07-31-2020 at 10:36 AM. Reason: additional information
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

  3. #3
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,150

    Re: Excel to CSV - Date format with wrong output

    CSV files are actually plain text files and do not support formatting. So, everything should be done at the source file before importing.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Excel to CSV - Date format with wrong output

    CSV, unlike Excel file, is a flat file and will not hold any formatting or schema info. Those will be lost when file is saved.

    How you pass data from Excel to CSV will depend on CSV type. CSV is highly environment/Source system dependent.

    In your case, it is likely that your system uses region setting that uses U.S. format as default, and your Excel has different date format (culture) applied.

    It may be easier to read csv content into some sheet (via import wizard / code), then update values from your Excel file. And then save the sheet as CSV.

    If you need further help, I'd recommend uploading sample workbook and csv file. Clearly indicating your desired result. (see yellow banner at top).
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  5. #5
    Registered User
    Join Date
    04-22-2019
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    24

    Re: Excel to CSV - Date format with wrong output

    Thanks a lot guys it was helpfull

  6. #6
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,150

    Re: Excel to CSV - Date format with wrong output

    You're welcome and thx for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Date format wrong
    By randall78 in forum Excel General
    Replies: 10
    Last Post: 06-14-2018, 08:33 AM
  2. wrong date format
    By isurunk in forum Excel General
    Replies: 2
    Last Post: 03-12-2018, 03:32 AM
  3. Excel for Mac 2011: goal seek function produces bizarre output, what's wrong?
    By Vitale in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 05-18-2016, 01:23 AM
  4. Wrong date format being inserted
    By LP8721 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2015, 06:31 AM
  5. Date in Excel, Wrong cell format
    By Perito in forum Excel General
    Replies: 3
    Last Post: 01-09-2012, 09:47 AM
  6. Wrong Date Format in output userform
    By ABBOV in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2010, 06:58 AM
  7. Macro gives the wrong date format
    By chin_un_len in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2006, 08:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1