473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Exporting date fields to a text file

I am attempting to automate a process involving importing a .txt file into an existing table, changing a date in each record, then exporting the table, again as a .txt file. One field contains a date (yyyy-mm-dd) and another a date/time (yyyy-mm-dd hh:nn:ss). If I do the export manually, the exported data in the .txt file is correct, but if I automate the process using the transfertext action and an export specification, the date field exports with time (00:00:00) added to the date. It does this whether those fields in the existing Access table are text fields or date/time fields. How can I prevent Access from adding time to the exported data in the date only field? The time characters don't appear in the Access table, only in the exported .txt file.
Mar 15 '07 #1
16 12403
I am attempting to automate a process involving importing a .txt file into an existing table, changing a date in each record, then exporting the table, again as a .txt file. One field contains a date (yyyy-mm-dd) and another a date/time (yyyy-mm-dd hh:nn:ss). If I do the export manually, the exported data in the .txt file is correct, but if I automate the process using the transfertext action and an export specification, the date field exports with time (00:00:00) added to the date. It does this whether those fields in the existing Access table are text fields or date/time fields. How can I prevent Access from adding time to the exported data in the date only field? The time characters don't appear in the Access table, only in the exported .txt file.
I'm using Access 2003 on Windows 2000.
Mar 15 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
I am attempting to automate a process involving importing a .txt file into an existing table, changing a date in each record, then exporting the table, again as a .txt file. One field contains a date (yyyy-mm-dd) and another a date/time (yyyy-mm-dd hh:nn:ss). If I do the export manually, the exported data in the .txt file is correct, but if I automate the process using the transfertext action and an export specification, the date field exports with time (00:00:00) added to the date. It does this whether those fields in the existing Access table are text fields or date/time fields. How can I prevent Access from adding time to the exported data in the date only field? The time characters don't appear in the Access table, only in the exported .txt file.
Regardless of how the field is formatted Access stores it with the time. Try changing the format of the field to "mm/dd/yyyy" and see if that works.

Mary
Mar 17 '07 #3
Shal
10
I have the same issue.
I run a script that is simply dumping a table into a text file for another user to pick up. The attributes of the date's fields are set to "Short Date" and they display only the date in Access. The issue comes when the text file is viewed, all the rest of the data is fine but the Date has had a time added. The time fields have also had a date from year 1899 added. This is an issue for me as I need to export into fixed length fields.
I changed the attributes of the date and time fields in Access to be dd/mm/yyyy and time of 00:00 in the Input Mask but to no avail.

Please help

By the way I am also using Access 2003
Sep 10 '07 #4
Shal
10
I was able to fix this in the most part by defining the dates as text in the Export Specification while leaving them as Short Date etc in their attributes in the table in Access.

My only issue now is that the last 2 spaces of my date field are being cut off in the text file such as below:

339581 20/03/20 9:51:00 20/03/20 9:52:00
434106 27/03/20 3:11:00 27/03/20 3:11:00
434107 30/03/20 4:31:44 30/03/20 4:31:53

The width of each of the date fields is 10 so I don't know why only the first 8 are showing. The width of the time fields is 8.
Sep 10 '07 #5
Shal
10
I now have set the date field to be only 10 characters in the Export Specification and this chops off the added on time for the date field. So the date information in the text file is now usable.

I can't do this for the time fields though because the Date gets added on before the time is printed and you can't tell the Export specification to only start from somewhere after the beginning of that field. I also ask for the time in Short Time format which is supposed to (and does in the datasheet view in Access) display the time in 24 hour time. This then stops me changing the format of the time field to text in the export specification as I don't get the 24 hour time display and if I use medium setting for the time in Access I don't get the AM/PM part exported unless I choose Date/Time as the export format for it.

Interesting....
Sep 11 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
I now have set the date field to be only 10 characters in the Export Specification and this chops off the added on time for the date field. So the date information in the text file is now usable.

I can't do this for the time fields though because the Date gets added on before the time is printed and you can't tell the Export specification to only start from somewhere after the beginning of that field. I also ask for the time in Short Time format which is supposed to (and does in the datasheet view in Access) display the time in 24 hour time. This then stops me changing the format of the time field to text in the export specification as I don't get the 24 hour time display and if I use medium setting for the time in Access I don't get the AM/PM part exported unless I choose Date/Time as the export format for it.

Interesting....
Open the export wizard and don't open the advanced tab. In the window which shows the lines which separate the text fields for export try dragging the lines to the appropriate places. Then open the advanced tab and see what lengths wizard has given to the fields.

If your data is stored as text try using quotes on the text fields and see if that helps.
Sep 11 '07 #7
Shal
10
Thanks for the reply.

I tried to move the lines separating the text fields. They moved fine, the reason it doesn't help me is that you can move the right side of a field and adjust the field's width but not the left. If you move the left line of the field it narrows the field to the left of the line not to the right. Hence I can't chop off the start of the text in a particular field and can't remove the added in Date reference to a time field.

The time is an auto generated time in the Access database using the method =Time(), unfortunately this means the data coming to me in the table is not readily changed by means of adding quotes. I would still want it as time anyway and the only place I have changed it to text is in the export specification.

I actually need the time to be printed out in the text file in the format 00:00 as a minimum but prefereably 00:00:00. My other issue is that I need leading zeros on this field as well if the time is less than 10am in the morning. EG - 09:51:52

Maybe Access just isnt capable of doing this and I need to write a procedure to pull that field out of the recordset and format it and then write it back in again.

What do you think?
Sep 12 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
Thanks for the reply.

I tried to move the lines separating the text fields. They moved fine, the reason it doesn't help me is that you can move the right side of a field and adjust the field's width but not the left. If you move the left line of the field it narrows the field to the left of the line not to the right. Hence I can't chop off the start of the text in a particular field and can't remove the added in Date reference to a time field.

The time is an auto generated time in the Access database using the method =Time(), unfortunately this means the data coming to me in the table is not readily changed by means of adding quotes. I would still want it as time anyway and the only place I have changed it to text is in the export specification.

I actually need the time to be printed out in the text file in the format 00:00 as a minimum but prefereably 00:00:00. My other issue is that I need leading zeros on this field as well if the time is less than 10am in the morning. EG - 09:51:52

Maybe Access just isnt capable of doing this and I need to write a procedure to pull that field out of the recordset and format it and then write it back in again.

What do you think?
OK, now I understand what you are trying to do.

Create a separate field to enclose the section you don't want exported. Now in the Advanced wizard under Field information there is a tickbox column called skip. Tick the box beside that field and it won't export.
Sep 12 '07 #9
Shal
10
Thanks again, seemed like an easy solution but I must be doing something wrong. When I went into the export specification and added a new field so that I could chop the time into date and a time sections, trying to save that spec or hit ok brought up the error message :

"The number of fields in your export specification does not match the number of fields in the table you have chosen to export."

Even so, when I move the lines (that define the widths of each field) to get just the date portion of the time field, the time part disappears as if covered over by the field to the right. So I wouldn't be able to set any other field to be the time part of this field.
Sep 12 '07 #10
Shal
10
I created a dummy extra field in the Database in case this is what was suggested and re set up the Export Specification. I then checked if I could set the start and end of fields to split up what is getting exported for the time reading but could not.
Sep 12 '07 #11
MMcCarthy
14,534 Expert Mod 8TB
I created a dummy extra field in the Database in case this is what was suggested and re set up the Export Specification. I then checked if I could set the start and end of fields to split up what is getting exported for the time reading but could not.
In your query do the following ...

Format([DateField], "dd/mm/yyyy") As DateSection, Format([DateField], "hh:nn" As TimeSection)

instead of the DateField as it is now.
Sep 12 '07 #12
Shal
10
Now I am getting somewhere, thanks for that.

I had to re-write my query in the module because it was just a
SELECT * FROM XXXX
type one before, but with the formatting in it I am pretty close to done now. The other thing I think I was missing is that the Export Specification needed to be applied to the query not the table.

I am getting an error telling me XX records will be deleted each time I run it but I can't see anything in the table being deleted. Is this just referring to the query records?

I appreciate all the help
Sep 13 '07 #13
MMcCarthy
14,534 Expert Mod 8TB
Now I am getting somewhere, thanks for that.

I had to re-write my query in the module because it was just a
SELECT * FROM XXXX
type one before, but with the formatting in it I am pretty close to done now. The other thing I think I was missing is that the Export Specification needed to be applied to the query not the table.

I am getting an error telling me XX records will be deleted each time I run it but I can't see anything in the table being deleted. Is this just referring to the query records?

I appreciate all the help
This sounds very strange. That warning usually only comes up when you are deleting records from the table.
Sep 13 '07 #14
Shal
10
Other than the error message coming up everything is now fine. I also can't find anything actually being deleted so I am running with it for now.

Thanks again for the help
Sep 14 '07 #15
jamjar
50
This sounds very strange. That warning usually only comes up when you are deleting records from the table.
I'm having the same problem. It occurs if I use Format in my query to try to control the date/time text output. The DELETE warning appears when I perform the TransferText and if I proceed, no source records are deleted, but what I'm seeing is that the formatted date fields are not exported to my text file (blanks appear where the dates should be).

If I remove the Format function from my query there is no Delete message, and all fields are exported, just in the wrong format ....
Sep 25 '07 #16
jamjar
50
I'm having the same problem. It occurs if I use Format in my query to try to control the date/time text output. The DELETE warning appears when I perform the TransferText and if I proceed, no source records are deleted, but what I'm seeing is that the formatted date fields are not exported to my text file (blanks appear where the dates should be).

If I remove the Format function from my query there is no Delete message, and all fields are exported, just in the wrong format ....
The Delete warning appears in my case because I forgot to change the Export Specification to recognise the Date field as Text after using the Format function. Once I fixed this, the TransferText works fine.

James
Sep 25 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Fran Zablocki | last post by:
I have a process that exports an Access table to a comma-delimited text file. One of the fields that is exported shows the date it was exported, using the Date() function. In the Access table, the...
4
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear"...
0
by: Otis Hunter | last post by:
I have been fighting with this for days and your expert help is needed! Below is the code I am executing which results with "Object doesn't support this property or method". The error is occuring...
1
by: Big Time | last post by:
I'm exporting a large amount of data from one of my tables into a tab delimited text file. The problem is the fields that have date format come out in MM/DD/YY HH:MM:SS format when what I want is...
1
by: warlord | last post by:
In order to save typing, I've borrowed the text from a post of nearly 12 months ago.....but the problem still exists. I've been banging my head all day with this, so I'm hoping someone has some...
6
by: Kevin Chambers | last post by:
Hi all-- In an attempt to commit an Access MDB to a versioning system (subversion), I'm trying to figure out how to convert a jet table's metadata to text, a la SaveAsText. The end goal is to...
20
by: czarbjones | last post by:
Hey Gurus, I'm trying to export a query (QueryDataExport) to a comma delim CSV file. The file name should look like this "C:\DSF_20061127_124211.csv" however it is exporting as "C:\DSF_.csv". ...
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
3
by: jrnowlan | last post by:
I have the following code that takes form data from a picklist and uses the input values to query an access database. Currently everything works, but it writes the results to the same page when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.