I have created a macro to export the contents of a query as a csv file, but when I open the csv file, the date is showing the date and time. I need it to only show the date as this csv file is uploaded to a parcel carrier's system that will only accept this field as dd/mm/yyyy.
The date is created in an access table as a default value in the cell. The format is set to "Short date", the input mask to "00/00/000" and the default value to "Date()".
The query field is also set the same. The date format appears correctly in both the table and the query, but when it is exported it somehow changes to date / time format.
When I checked the cell format in the csv file it shows as a custom format "dd/mm/yyyy hh:mm"
This file is overwritten every time I run the macro and in fact when I ran it for the first time, it created the csv file so it can't be due to a preformatted file problem.
Would greatly appreciate any help on this - it's prevent us from automating our despatch processes.
Last edited by MikeWaring; 11-30-2010 at 08:52 AM.
You could modify your macro to either reformat the date prior to save or to create a temporary CSV fule which you then process to create the real one, again with reformatting.
To reformat, you could try using the LEFT function specifing the 10 left most characters which will trim off the time.
If you need extra help, you will need to post a copy of the CSV file so that folk can see the format.
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
In your query, create a new field with the expression =Int([your field name containing date]. Export this and not the current date field. Access saves dates as a serial number and formatting is only a presentation. It is not changing the value. This is especially important if you are having Access create the date as it will create it as a value similar to 43567.12387 which is the date and time in serial format. This is how it is saved. Formatting changes only how you see it.
Alan
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
Hi both, thanks for your suggestions. I'm working on another part of the database right now, but I'll try these solutions when I go back to that part of the project. I'm sure both will work, but if I have problems I'll open a new post.
Thanks again.![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks