Access export date and time fields and keep certain format

Posted on 2009-07-06
Last Modified: 2013-11-27
I have a query that I am exporting and need to keep the format a certain way.
the date needs to look like this

20090707 for July 7, 2009

I have the format correct in the query but when I export it it turns to this.

7/7/2009 1:47:58 PM

Same with the time - I have it set to HHMMSS
hour minute second
and when exporting I get

1:47:58 PM

Question by:Pdeters
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
  • 2
LVL 17

Expert Comment

ID: 24788110
FORMAT([Table].[Field], "yyyyMMdd")
Wouldn't this work.
LVL 17

Accepted Solution

pssandhu earned 500 total points
ID: 24788135
Also, if you are exporting the result into another table then make sure the target column default format is set to yyyyMMdd. You can set this in the table design mode.

Author Closing Comment

ID: 31600302
I put in the query as it is not pulling a date but using today's date



Expert Comment

ID: 24788312
You can also try

date_format([table].[fld], '%Y%m%d')
#should print "yyyymmdd" 20090631


date_format([table].[fld], '%h%i%s')
#should print "hhmmss"

query usage:
$query = "SELECT date_format(datefld , '%Y%m%d') FROM ourTable";

Hope this helps.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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 …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

623 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