Solved

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

Posted on 2011-09-19
8
358 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

778 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