What is the .NET way? - Right("0" & Now.Month.ToString, 2)

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
T

Terry Olsen

This is the easiest way I can think of to do this:
tmp=Right("0" & Now.Month.ToString, 2)

The only way I've figured to do it the .NET way is this:
tmp="0" & Now.Month.ToString
tmp=tmp.substring(tmp.length-3)

Surely, there's a more elegant way?
 
Now.ToString("MM")

Go to DateTime.ToString in the help file and start following links around
until you find the table of datetime format strings.

Tom Dacon
Dacon Software Consulting
 
Terry Olsen said:
This is the easiest way I can think of to do this:
tmp=Right("0" & Now.Month.ToString, 2)

The only way I've figured to do it the .NET way is this:
tmp="0" & Now.Month.ToString
tmp=tmp.substring(tmp.length-3)

Surely, there's a more elegant way?

\\\
MsgBox(Now.ToString("MM"))
MsgBox(Now.Month.ToString("D2"))
///
 
Herfried,

Tom (and I) were trying to teach Terry how to fish, we probably both know
how we have to give that fish.

:-)

Cor
 
Back
Top