ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exporting Date to Text File (https://www.excelbanter.com/excel-programming/303521-exporting-date-text-file.html)

Dan T[_2_]

Exporting Date to Text File
 
Hi,
I'm writing a macro that exports a range to a text file which will ultimately be uploaded to a database. This upload requires the date to be in a specific format, ie. dd-mmm-yy. When I use the open command to write to, it automatically puts it in a yyyy-mm-dd format. Is there a way to force the dd-mmm-yy format when outputting to text file with the write command?

K Dales

Exporting Date to Text File
 
The Write statement automatically converts date to
universal date format, i.e. the yyyy-mm-dd you are
getting. You can force the conversion to another format
by using the format function: Format(DateVar,"dd-mmm-yy").

So, for example:
Write#1 Var1, Var2, Format(DateVar,"dd-mmm-yy"),...

-----Original Message-----
Hi,
I'm writing a macro that exports a range to a text file

which will ultimately be uploaded to a database. This
upload requires the date to be in a specific format, ie.
dd-mmm-yy. When I use the open command to write to, it
automatically puts it in a yyyy-mm-dd format. Is there a
way to force the dd-mmm-yy format when outputting to text
file with the write command?
.


Dave Peterson[_3_]

Exporting Date to Text File
 
Maybe you can write the formatted date:

..... format(myCell.value, "dd-mmm-yyyy")...



Dan T wrote:

Hi,
I'm writing a macro that exports a range to a text file which will ultimately be uploaded to a database. This upload requires the date to be in a specific format, ie. dd-mmm-yy. When I use the open command to write to, it automatically puts it in a yyyy-mm-dd format. Is there a way to force the dd-mmm-yy format when outputting to text file with the write command?


--

Dave Peterson



All times are GMT +1. The time now is 01:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com