Solved

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

Posted on 2011-09-19
8
356 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
  • 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now