469,913 Members | 2,683 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

get the month (number) and year value from a date

Hi,

How do I extract just the month part of a date. Say for example I wanted to
get the value of 6 (as in sixth month) from todays date.

Regards


Jun 20 '06 #1
3 32530
"Aussie Rules" <Au*********@nospam.nospam> schrieb:
How do I extract just the month part of a date. Say for example I wanted
to get the value of 6 (as in sixth month) from todays date.


\\\
Dim Month As Integer = Now.Month
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 21 '06 #2
Hi Aussie,

Thank you for posting.

If you have a variable of type DateTime, you could use the Month property
to get the month part of the date.

For example, you could get the month part of today by the following
statement:
dim month as Integer
month = DateTime.Today.Month
// or
month = DateTime.Now.Month

If you have any questions, please don't hesitate to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 21 '06 #3
Linda,

I don't think it is right to give converted C# code while there is better VB
code.

Have a look what Herfried has showed,

Just my opinion.

Cor

"Linda Liu [MSFT]" <v-****@online.microsoft.com> schreef in bericht
news:7q**************@TK2MSFTNGXA01.phx.gbl...
Hi Aussie,

Thank you for posting.

If you have a variable of type DateTime, you could use the Month property
to get the month part of the date.

For example, you could get the month part of today by the following
statement:
dim month as Integer
month = DateTime.Today.Month
// or
month = DateTime.Now.Month

If you have any questions, please don't hesitate to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Ante Perkovic | last post: by
34 posts views Thread by prosoft | last post: by
reply views Thread by larry | last post: by
22 posts views Thread by Stan | last post: by
20 posts views Thread by Highlander | last post: by
6 posts views Thread by Nkhosinathie | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.