I need to import a csv file to my access that contains a datetime column in format dd/mm/yyyy hh:mm:ss
Here is what I'm currently doing
DoCmd.TransferText acImportDelim, "my_specification", "temp_table", filePath, True
updateQuery = "Update my_table " _
& "INNER JOIN " _
& "(SELECT field1, field2, field_date " _
& "FROM temp_table) " _
& "ON my_table.field1 = temp_table.field1 AND my_table.field2 = temp_table.field2 " _
& "SET my_table.field_date = temp_table.field_date " _
& "WHERE my_table.field_date IS NULL"
I use TransferText to store the csv file content temporarily into a table. "my_specification" is used to specify the date time column format as dd/mm/yyyy hh:mm:ss.
Then I use an update query to update the date time field from the temp table.
However, problem here is temp_table.field_date format will vary according to user's system locale setting. If my user has mm/dd/yyyy as their system setting, it creates a wrong update in my_table.
To describe better the problem, take date 2014 Aug 4 as an example. In CSV file, it is stored as 04/08/2014 12:12:12. Then it is imported the same into my temp_table field_date column.
The factor of user's locale setting comes in when I update my_table. If my user sets system date format as dd/mm/yyyy, then it can be read correctly as 2014 Aug 4. However, if my user sets system date otherwise as mm/dd/yyyy, then the date will be read as 2014 Apr 08.
Is there anyway I can enforce an unambiguous date time format for this update?
I'm using MS Access 2013, but I hope the database can be compatible with Access 2003 as well.
Thank you.