Solved

Date format in CSV export

Posted on 2011-03-22
11
866 Views
Last Modified: 2012-05-11
From an Access database, I am exporting the result of a Query, as XLS (Excel) and also as a CSV file. The Excel dates come out correctly, e.g. "22/03/2011", but the CSV dates also give the time part  which I don't want, e.g. " 22/03/2011 00:00:00". I just want "22/03/2011" in the CSV as well. Any idea how I can fix this? Thanks.
0
Comment
Question by:DataTrain
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35190855
in your query, change the date column to

dateValue([dateField])
0
 

Author Comment

by:DataTrain
ID: 35191235
Thanks for the suggestion but that doesn't make any difference.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35191258
how are you exporting the query as csv?
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 35191346
Actually, if you formatted the cells as date/time, they probably would also show the time part.
Please post your query SQL.
0
 
LVL 12

Accepted Solution

by:
telyni19 earned 125 total points
ID: 35191708
Try Format([DateField],"mm/dd/yyyy") for your query's date column definition. That should export the date as formatted text.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 4

Expert Comment

by:MeLindaJohnson
ID: 35191854
I think you want format([datefield]. "dd/mm/yyyy")
0
 
LVL 4

Expert Comment

by:MeLindaJohnson
ID: 35191860
should be a comma after [datefield] in post before.
0
 

Author Comment

by:DataTrain
ID: 35191892
I don't believe the SQL is the issue as the date format it generates is correct and the XLS output is also correct. So I think it is something to do with the export to CSV. This is the command I am using: DoCmd.TransferText acExportDelim, , stqueryname, strSaveFileName
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35191939
dataTrain, try the Format suggestion by telyni19, that should do it..
0
 
LVL 4

Expert Comment

by:MeLindaJohnson
ID: 35191976
If you want days, months, year then "dd/mm/yyyy".  If you want months, days, year then use "mm/dd/yyyy".  Your example shows days,month,year.

...copied from above....  I just want "22/03/2011" in the CSV as well.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35192020
FYI.
MeLindaJohnson,
you are basically repeating another experts earlier post at http:#a35191708
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

18 Experts available now in Live!

Get 1:1 Help Now