Formatting Day() Function results

L

Loyd

I am using the day() function to create an invoice number based on the date
of the invoice. My problem is that the results of the day() function for the
first 9 days of any month only generates a one digit number.

How can I format the results so that day(2009/1/4) results in a 2-digit
number, 04, instead of 4?

Appreciate any help.
 
R

Rick Rothstein

Where do you need this two-digit day number at? If in a worksheet cell, then
Gord has given you your answer. If, on the other hand, you need this within
your VB code (you posted to the programming newsgroup, so I'm assuming you
are writing VB code), then Dim the receiving variable as a String (numeric
variables cannot hold formatting)...

Dim DayNum As String

and then assign the two-digit day number to it like this...

DayNum = Format(YourDate, "dd")

where YourDate is a valid date value.
 

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