Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-19
8
Medium Priority
?
364 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 450 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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 1050 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

688 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