473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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 ***
Aug 18 '06 #1
5 3105
tmp = now.month.tostring("00") should do the trick.

Mike.

"Terry Olsen" <to******@hotmail.comwrote in message
news:%2****************@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 ***

Aug 18 '06 #2
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" <to******@hotmail.comwrote in message
news:%2****************@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 ***

Aug 18 '06 #3
In addition to Tom,

The IFormatProvider for dates

http://msdn2.microsoft.com/en-us/lib...ormatinfo.aspx

I hope this helps,

Cor

"Terry Olsen" <to******@hotmail.comschreef in bericht
news:%2****************@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 ***

Aug 18 '06 #4
"Terry Olsen" <to******@hotmail.comschrieb:
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/>
Aug 18 '06 #5
Herfried,

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

:-)

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:uL**************@TK2MSFTNGP04.phx.gbl...
"Terry Olsen" <to******@hotmail.comschrieb:
>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/>

Aug 18 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Evgeny Gopengauz | last post by:
What is the way recommended by Microsoft for distributing the MSSQL database with end-user application if I don't like to use sql-scripts because I need to hide the stored procedures sources (they...
5
by: junky_fellow | last post by:
Each time i submit some pattern to "google", it shows search took 0.XX seconds for exploring millions of web pages. When i look for efficient ways of searching a string, they always say compare...
1
by: Edward King | last post by:
I have a statement in a asp,like follows£º var str=window.top.main.document.all.contenttext.value; I use IIS5.0 to deploy this asp,then I visit this asp like follows:...
6
by: Dean Slindee | last post by:
I am looking for the "right" way to handle inserting and presenting null date values. Public Const c_NullDate As Date = #12:00:00 AM# If I set the value of a date variable in an SQL Server insert...
6
by: MilanB | last post by:
Hello What "0&" means in this function call? ret = InternetQueryOption(0&, INTERNET_OPTION_CONNECTED_STATE, _ ci, ci_len) Thanks Milan
44
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute...
1
by: tshad | last post by:
I have columns with text and radio buttons that I would like to center or put to the right of the cell, but the attribute ItemStyle-HorizontalAlign="right" doesn't seem to work. ...
8
by: Chaitanya | last post by:
Hello, In my Application i want to know when user clicks both the "Left" and "Right" buttons of the Mouse. I am getting a number like this "3145728". But the MouseButtons Enum contains only Left,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.