Home All Groups Group Topic Archive Search About

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

Author
20 Jun 2006 10:17 PM
Aussie Rules
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

Author
21 Jun 2006 12:30 AM
Herfried K. Wagner [MVP]
"Aussie Rules" <AussieRules@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/>
Author
21 Jun 2006 1:49 AM
Linda Liu [MSFT]
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.
====================================================
Author
21 Jun 2006 5:25 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Linda Liu [MSFT]" <v-l***@online.microsoft.com> schreef in bericht
news:7qjWHUNlGHA.2260@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.
> ====================================================
>