Date format question

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
 
D

Duane Hookom

Use & rather than + for concatenating strings.
txtFile = txtFile & "Ship" & Format(Date,"yyy) + Format(MonthNo, "00") &
"0001.XYZ.CSV"
 
D

Douglas J. Steele

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"
 
D

Duane Hookom

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")?
 
D

Douglas J. Steele

Oh. And here I thought you were letting Jackson help you answer questions!
<g>
 
D

Duane Hookom

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 ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top