I am putting date.today into a variable called dte but I want to convert the date format from, for example, 12/10/2006 to 20061210. How can I do this? I know it's probably something simple but I can't seem to find the answer.
If you need leading zeroes on days and months that are less than 10 (e.g., 9/9/2006), then do this:
DateString = Year(dt).ToString
If Month(dte) < 10 Then
DateString &= "0" & Month(dte).ToString
Else
DateString &= Month(dte).ToString
End If
If Day(dte) < 10 Then
DateString &= "0" & Day(dte).ToString
Else
DateString &= Day(dte).ToString
End If
I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.