Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a 0 to the day for dd/mm/yy 1

Status
Not open for further replies.
Jul 13, 2001
180
US
Hello,

My dates are coming up as 1/5/04, I need to show as 1/05/04.
How do you do that?

Thanks in advance,
 
Try something like this:
Right("0" & Day(Date),2)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hello PHV,

Unfortunately that adds a 0 to ALL dates including 1-9.
Is there another way?

Thanks again.
 
Can you please be more explicit on how are coming your dates ? i.e. post input examples and expected result.
 
My bad!!
I should have drank the coffee first.

Thank you PHV.
You rock.
 
goatnorm, can you please post a working example in VBScript ?
 
Option Explicit
Sub Main
Dim varDate as String

varDate = "2003-05-04"

MsgBox(Format(varDate, "m/dd/yyyy"))
end sub
 
goatnorm, can you please post a working example in VBScript, not VBA nor VB.
 
Here is an example using the date() function but you can substitute it for any date variable you wish:
Code:
month(date())&"/"&right("0"&day(date()),2)&"/"&right(year(date()),2)
dbMark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top