Solved

How to convert to date/time in MS ACCESS with this format 20110916160401

Posted on 2011-09-19
8
362 Views
Last Modified: 2012-05-12
Hi I have csv files I need to start importing into an access database. One of the columns in the csv is the date/time, but the column is just a number like: 20110916160401 which I think is year(2011), month(09), day(16), time(16:04:01)

Is there a way to configure the MS Access 2007's table column as Data/Time to convert this string to correct date/time?

Thanks for any input.
0
Comment
Question by:Mark B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 26

Assisted Solution

by:Nick67
Nick67 earned 150 total points
ID: 36564190
<configure the MS Access 2007's table column as Data/Time>
You are importing--but how are you importing.
The conversion will need to be done during the import.
If you do an external data import, and a text file import, there is an 'advanced' button
In your case you are looking to tell it that you have no delimiters and leading zero.
Access should then properly convert your file on import
0
 

Author Comment

by:Mark B
ID: 36564239
Well, I'm importing the csv data into MS Access 2007 and attached are advanced settings I've tested. It generates a type conversion error in import for the date field that has 20110916160401 date/time string information and the column I've designated as date/time doesn't have any values. I was wondering if there is something under design view of the table in the general settings for data/time data type that needs to be configured.
import.jpg
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 36564249
>>Zones: Microsoft Access Database, SQL Server 2005, Microsoft Excel Spreadsheet Software<<
Has this gone anything to do with SQL Server 2005?
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:Mark B
ID: 36564287
Well, the main task at hand is how to convert the string data for date/time in the supplied csv file to actual date/time. I should have mentioned we are open to MSSQL 2005 ideas as well and have started investigating in MS Access first. Overall, I am looking for any information on how to convert this date/time number information in the supplied csv we are receiving to true date/time column information in any of the three MS products so we can manage data by date.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 350 total points
ID: 36564319
>> I should have mentioned we are open to MSSQL 2005 ideas as well and have started investigating in MS Access first. <<
If you are importing it into SQL Server, then always, always import it first into a staging table.  This has two advantages:
1. It is far faster to do it this way, as you are not converting row by row and more importatantly
2. This allows you to validate, prior to importing into your Production tables.  Remember the old axiom: Garbage in, garbage out.

Once it is in a staging table depending on the algorithm used to encode it, it should be trivial with T-SQL to convert that string to a datetime value. Using something like this:
SELECT CONVERT(datetime, STUFF(STUFF(STUFF(STUFF(STUFF(@Dat, 9, 0, ' '), 5, 0, '-'), 8,0, '-'), 14, 0, ':'), 17, 0, ':'), 120)

CONVERT(
0
 

Author Comment

by:Mark B
ID: 36564742
Using the solution on this page in MS Access. It's about using a query to format this type of data/time data: yyyymmddhhmmss I found another one for excel as well.

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_21997515.html?sfQueryTermInfo=1+10+30+access+ms+yyyymmddhhmmss
0
 

Author Closing Comment

by:Mark B
ID: 36564752
The T-SQL was the clue I needed to solve this puzzle. It's about preserving the original data input and then using a query to program the result. This approach will easily help us bulk import the raw data and then config queries to export the data in the needed human readable format.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 36565254
The staging approach is good, too
Depending on how huge the import was either a query or VBA to convert the text could have been written.
Sounds like that's what you did.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question