phweston
Programmer
- May 8, 2003
- 38
I am in the process of exporting a text file, and I need to name it using the current date and some text as the file name.
The nameing convention goes something like:
YYYYMMDDhhmmss_sometext
When I set this up using Month and Day functions, I would like to see the single digit months, days, hours, minutes, and seconds to show up as 2 digits.
For example, if I use Month(now), this will return a "9", instead of "09". I tried using the Format function, but that doesn't work. Any suggestions.
Here is part of the code that I am using:
SaveDate = Now
YearDate = Year(SaveDate)
MonthDate = Format(Month(SaveDate), mm)
DayDate = Format(Day(SaveDate), dd)
HourDate = Hour(SaveDate)
MinuteDate = Minute(SaveDate)
SecondDate = Second(SaveDate)
exportfile = YearDate _
& Format(MonthDate, mm) _
& Format(DayDate, dd) _
& Format(HourDate, hh) _
& Format(MinuteDate, mm) _
& Format(SecondDate, ss) _
& "_holdings"
DoCmd.TransferText acExportDelim, "Testexport Export Specification", "tblCharfinalData", "s:\federated\_technology\" & exportfile & ".txt", no
The file name came out as "200393112254_holdings"
The nameing convention goes something like:
YYYYMMDDhhmmss_sometext
When I set this up using Month and Day functions, I would like to see the single digit months, days, hours, minutes, and seconds to show up as 2 digits.
For example, if I use Month(now), this will return a "9", instead of "09". I tried using the Format function, but that doesn't work. Any suggestions.
Here is part of the code that I am using:
SaveDate = Now
YearDate = Year(SaveDate)
MonthDate = Format(Month(SaveDate), mm)
DayDate = Format(Day(SaveDate), dd)
HourDate = Hour(SaveDate)
MinuteDate = Minute(SaveDate)
SecondDate = Second(SaveDate)
exportfile = YearDate _
& Format(MonthDate, mm) _
& Format(DayDate, dd) _
& Format(HourDate, hh) _
& Format(MinuteDate, mm) _
& Format(SecondDate, ss) _
& "_holdings"
DoCmd.TransferText acExportDelim, "Testexport Export Specification", "tblCharfinalData", "s:\federated\_technology\" & exportfile & ".txt", no
The file name came out as "200393112254_holdings"