Solved

Export from access to excel

Posted on 2013-01-07
5
448 Views
Last Modified: 2013-01-17
Hi,

I have an access-table with many fields with a time format hh:nn:ss.
With a query i select the records that i want.
When i do an export to excel with code :
DoCmd.TransferSpreadsheet acExport, 8, stDocName, Pad, True, ""
then i get in excel 00:01/1900 08:30 and i see 00/01/1900.
What i want is to see 08:30.
When i export the table then everything is ok.
I have set the format to "Long Time" but that gives also the wrong result.

How can i solve this?

Tx
0
Comment
Question by:sonmic
5 Comments
 
LVL 39

Expert Comment

by:als315
ID: 38750425
You can convert time to text before export or simply change format of cell in Excel (set it to h:mm)
0
 
LVL 77

Expert Comment

by:peter57r
ID: 38750577
You can force a format in your query...

MyTime:format(Timefield, "hh:nn:ss")

but this will be passed as text into Excel
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38751426
Is the table data actually a Date/Time datatype, ...or is it Text.?
Because a "Time" will generally include a "date" of some sort.

I usually get out the hammer and create a Numeric (Double datatype) field in a query form the "Time" field, ...and export that to Excel, then you should be able to format the Excel sheet for "Time" and get back the correct format.

*However*, you should be able to just set the Format for that filed in Excel to "Time" to get the same time format is you had in Excel.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38751477
This DB works fine for me and produces an Excel like the one attached (again, you will have to format the field in Excel for "Time")
Database22.mdb
YourTable.xls
0
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 38757035
If these fields are truly date fields, you might export a query instead of a table.  In the query, you would format the column to hours and minutes.
Example:
Select FORMAT([My Date Column Name], "hh:nn") 
From [My Table Name]

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

863 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

20 Experts available now in Live!

Get 1:1 Help Now