|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What is the .NET way? - Right("0" & Now.Month.ToString, 2)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? *** Sent via Developersdex http://www.developersdex.com *** tmp = now.month.tostring("00") should do the trick.
Mike. Show quoteHide quote "Terry Olsen" <tolse***@hotmail.com> wrote in message news:%23kykMZuwGHA.4460@TK2MSFTNGP04.phx.gbl... > > 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? > > > *** Sent via Developersdex http://www.developersdex.com *** 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 Show quoteHide quote "Terry Olsen" <tolse***@hotmail.com> wrote in message news:%23kykMZuwGHA.4460@TK2MSFTNGP04.phx.gbl... > > 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? > > > *** Sent via Developersdex http://www.developersdex.com *** In addition to Tom,
The IFormatProvider for dates http://msdn2.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx I hope this helps, Cor Show quoteHide quote "Terry Olsen" <tolse***@hotmail.com> schreef in bericht news:%23kykMZuwGHA.4460@TK2MSFTNGP04.phx.gbl... > > 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? > > > *** Sent via Developersdex http://www.developersdex.com *** "Terry Olsen" <tolse***@hotmail.com> schrieb: \\\> 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")) /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Herfried,
Tom (and I) were trying to teach Terry how to fish, we probably both know how we have to give that fish. :-) CorShow quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht news:uLfEy8uwGHA.4280@TK2MSFTNGP04.phx.gbl... > "Terry Olsen" <tolse***@hotmail.com> schrieb: >> 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")) > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> |
|||||||||||||||||||||||