Date format question

  • Thread starter Thread starter JB_96RS
  • Start date Start date
J

JB_96RS

Hello y'all. I was wondering how to fix the format of a date. I am
using Access 2000. Access is creating a file for me and the date is
part of the file name. I need the date to appear as 20040107, but it
is showing 200417. How do I get the 0's to show? Here is the code I
am using now:

txtFile = txtFile + "Ship" + CStr(Year(Date)) + Format(MonthNo, "00") +
CStr(Month(Date)) + CStr(Day(Date)) + "0001" + ".XYZ" + ".CSV"


Any thoughts?


Thanks,

JB
 
Use & rather than + for concatenating strings.
txtFile = txtFile & "Ship" & Format(Date,"yyy) + Format(MonthNo, "00") &
"0001.XYZ.CSV"
 
Um, a couple of typos there, Duane! (one too few y's, and no closing quote)
<g>

And what's wrong with a simple Format$(Date, "yyyymmdd")?

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Duane Hookom said:
Use & rather than + for concatenating strings.
txtFile = txtFile & "Ship" & Format(Date,"yyy) + Format(MonthNo, "00") &
"0001.XYZ.CSV"
 
Thanks Doug, I installed some new software for a Bluetooth Explorer Mouse
and it seems that quite often when I type a Y, I loose some text. I'm not
sure why it happens since it is intermittent and just happens with the
letter y.

--
Duane Hookom
MS Access MVP


Douglas J. Steele said:
Um, a couple of typos there, Duane! (one too few y's, and no closing quote)
<g>

And what's wrong with a simple Format$(Date, "yyyymmdd")?
 
Oh. And here I thought you were letting Jackson help you answer questions!
<g>
 
We are both at the age that we sometimes don't make sense. At least I
haven't lost control of all of my functions ;-)
 
Back
Top