Results 1 to 2 of 2

Thread: [Solved] Save DateTime to .csv for import into MS Access

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    3

    [Solved] Save DateTime to .csv for import into MS Access

    My program outputs outputs a bunch of stuff to .csv files, which are destined to eventually be imported into MS Access. Now, everything works great except that I can't seem to figure out a way to save some DateTime variables that Access likes.

    First, I've tried using .ToOADate().ToString to print out the double that is used to represent the date. This actually works if I create a table in Access with all the columns and their types set, then append the data in the file to that. However, it does not work if I import the file as a new table and in the import wizard manually set the column type to Date/Time. I just get a type conversion error in that case.

    I've also just tried using .ToString to print out the string representation, but that also gives me a type conversion error during import.

    Is there a way to print my DateTime variable out so that it'll work both with creating new tables and appending to existing tables?

    Thanks.
    Last edited by zebeste; Jul 8th, 2010 at 05:51 PM. Reason: solved

  2. #2

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    3

    Re: Save DateTime to .csv for import into MS Access

    It never fails...

    I may have a solution.

    After manually adjusting the values in my .csv file to see how Access would react, apparently it does not like the AM and PM at the end of the string, which is why my attempts of using .ToString failed earlier. It also appears as though it accepts 24 hour time (i.e. 15:00 instead of 3:00 PM).

    What's weird is that even though it accepts the 24 hr time, it automatically converts it to 12 hr time and appends the AM or PM. WTH? Why couldn't it just accept the AM and PM in my .csv file

    Oh well, I'm off to figure out how to save my DateTime in 24 hr format (if anyone happens to know, I'd appreciate it if you could tell me and save me the time).

    EDIT: figured out how to do 24 hr time
    Last edited by zebeste; Jul 8th, 2010 at 05:50 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width