Solved

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

Posted on 2011-09-19
8
363 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

630 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