+ Reply to Thread
Results 1 to 4 of 4

Dataformat get mixed up in CSV file.

  1. #1
    Registered User
    Join Date
    02-28-2018
    Location
    Aalborg, Denmark
    MS-Off Ver
    2007
    Posts
    7

    Dataformat get mixed up in CSV file.

    I have some VBA code that generate a CSV file from a Customer database with dates (I need to reed the data in MailChimp).
    In the excelfile everything look finde all dates in column is in date format and written as i like dd-mm-yyyy hh:mm:ss (Danish format). (I don't need the time)
    But when I (using VBA) convert it to CSV file some of the dates at written incorrect:
    Some has changed to mm-dd-yyyy and what was "dd" is written as "mm" (Date of month it changed to month nr.). The cell is in danish date format dd-mm-yyyy
    Some has changed to mm/dd/yyyy (dont know if the date of month is changed to month nr.). The cell is in "standard" not date format and if i try to change it to date format (Danish dd-mm-yyyy) nothing happens.

    What can I do to make sure dates are being converted correctly in csv?

    Original:
    06-02-2018 (06-02-2018 17:02:29) (Read in cell)
    10-02-2018 (10-02-2018 13:04:54) (Read in cell)
    12-02-2018 (12-02-2018 10:20:58) (Read in cell)
    16-02-2018 (16-02-2018 12:25:35) (Read in cell)
    20-02-2018 (20-02-2018 14:55:01) (Read in cell)
    23-02-2018 (23-02-2018 14:41:08) (Read in cell)
    27-02-2018 (27-02-2018 10:31:35) (Read in cell)

    CSV file aften open in excel:
    02-06-2018 (Read in cell as the same whiteout time)
    02-10-2018 (Read in cell as the same whiteout time)
    02-12-2018 (Read in cell as the same whiteout time)
    2/16/2018 (Read in cell as the same whiteout time)
    2/20/2018 (Read in cell as the same whiteout time)
    2/23/2018 (Read in cell as the same whiteout time)
    2/27/2018 (Read in cell as the same whiteout time)
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Dataformat get mixed up in CSV file.

    If I save it as csv it remains the same

    I think you should not do save as csv but use a macro to generate the csv file and than you can include the date format when writing it

    This is typically one of the many issues with Excel and date and time formats.

    All dates before the 12th day of each month will work but after that the month and day get switched and Excel 'invents' it's version of it
    Attached Files Attached Files
    Last edited by Keebellah; 02-28-2018 at 04:34 AM. Reason: TypeOOO
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    02-28-2018
    Location
    Aalborg, Denmark
    MS-Off Ver
    2007
    Posts
    7

    Re: Dataformat get mixed up in CSV file.

    thank you but I'm not sure what you mean?
    I save using VBA macro:
    Filepath = ThisWorkbook.Path & "\"
    ActiveWorkbook.SaveAs FileName:=Filepath & "ServiceMailList.txt", FileFormat:=xlTextMSDOS, CreateBackup:=False

    Could you give me the VBA code i should use to get the dates correct?

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Dataformat get mixed up in CSV file.

    Since you did not post the workbook with the macro I had no idea what or how you were doing it.
    I don't know what more fields you have to export
    Take a look here for ideas: http://www.morgantechspace.com/2015/...-csv-file.html

+ 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. 1st name and 2nd name mixed up
    By Katyusa82 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-28-2017, 10:51 AM
  2. [SOLVED] VBA mixed references
    By cheesemeister in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-23-2016, 02:40 AM
  3. Mixed Messages
    By daffodil11 in forum The Water Cooler
    Replies: 2
    Last Post: 04-24-2015, 01:53 AM
  4. Excel file has mixed date formats
    By pushnoyj in forum Excel General
    Replies: 1
    Last Post: 02-14-2014, 07:45 PM
  5. Mixed graphs
    By Fennec123 in forum Excel General
    Replies: 2
    Last Post: 03-21-2010, 01:40 PM
  6. Excel 2007 : All mixed up and need help please!
    By DaveP51182 in forum Excel General
    Replies: 2
    Last Post: 02-27-2009, 04:51 PM
  7. Mixed Cell
    By prbucci in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-12-2006, 11:10 PM

Tags for this Thread

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