MS Access how to import string into Date/Time

Dear all,

I have an excel file that I'm importing into access.  One of the columns (fields to import) contains date information i.e. 01/05/2012 00:00:00 Tue.  When I import it into Access as a Date with Time I end up with import errors and it doesn't work.  I tried to change the format of the excel cells to Date but it makes no difference.

My next step is to link records by date, this table and another table where the Date is separate fields Month, Day, Timestep. The timestep is an integer from 1 to 48 for each day (half hourly data for one day).

How do I import this data into the database?  I don't need the actual day information (i.e. Tue).  Is it possible to parse the date using VB script or a macro into Year, Month, Day, Hour, Minute, Second etc.? Or include the timestep for the time?

Thanks
AndyC1000Asked:
Who is Participating?
 
Gustav BrockCIOCommented:
First import or link the Excel file where you specify the field as text.
Then pull the data via a query using the linked or imported table as source.
In this query, convert the string to a date using this expression:

    TrueDate: CDate(Mid([YourTextDateField],1,19))

If some records contains Null for this field, use CVDate:

    TrueDate: CVDate(Mid([YourTextDateField],1,19))

Also convert other fields as needed.
Now use this query as source when you proceed.

/gustav
0
 
PatHartmanCommented:
If the import is temporary, then stick with the query solution.  However, if the import is permanent, I would store the reformatted data in a proper date/time column.  Once the update is successful, then delete the original text column.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.