Get month name?

Get month name?

am 31.07.2006 10:55:01 von Edwin Knoppert

I can't find a way to obtain the months name from a date.
Like 'August'

Re: Get month name?

am 31.07.2006 11:34:07 von Morten Wennevik

Hi Edwin,

System.Globalization.DateTimeFormatInfo d =3D new =

System.Globalization.DateTimeFormatInfo();
=

string month =3D d.MonthNames[DateTime.Now.Month];


On Mon, 31 Jul 2006 10:55:01 +0200, Edwin Knoppert =
=

wrote:

> I can't find a way to obtain the months name from a date.
> Like 'August'
>
>



-- =

Happy Coding!
Morten Wennevik [C# MVP]

Re: Get month name?

am 31.07.2006 12:06:28 von Edwin Knoppert

Thanks it works however, how to use it without the culture thing?
My web.config already has the dutch culture.

DateTimeFormatInfo d = new CultureInfo("nl-NL", false).DateTimeFormat;
sVorigeMaand = d.MonthNames[DateTime.Now.AddMonths(-1).Month];

:)


"Morten Wennevik" schreef in bericht
news:op.tdjri5x9klbvpo@tr024.bouvet.no...
Hi Edwin,

System.Globalization.DateTimeFormatInfo d = new
System.Globalization.DateTimeFormatInfo();

string month = d.MonthNames[DateTime.Now.Month];


On Mon, 31 Jul 2006 10:55:01 +0200, Edwin Knoppert
wrote:

> I can't find a way to obtain the months name from a date.
> Like 'August'
>
>



--
Happy Coding!
Morten Wennevik [C# MVP]

Re: Get month name?

am 31.07.2006 12:59:39 von Edwin Knoppert

Got it :)

sVorigeMaand =
DateTimeFormatInfo.CurrentInfo.MonthNames[DateTime.Now.AddMo nths(-1).Month];


"Edwin Knoppert" schreef in bericht
news:44cdd65e$0$2021$ba620dc5@text.nova.planet.nl...
> Thanks it works however, how to use it without the culture thing?
> My web.config already has the dutch culture.
>
> DateTimeFormatInfo d = new CultureInfo("nl-NL", false).DateTimeFormat;
> sVorigeMaand = d.MonthNames[DateTime.Now.AddMonths(-1).Month];
>
> :)
>
>
> "Morten Wennevik" schreef in bericht
> news:op.tdjri5x9klbvpo@tr024.bouvet.no...
> Hi Edwin,
>
> System.Globalization.DateTimeFormatInfo d = new
> System.Globalization.DateTimeFormatInfo();
>
> string month = d.MonthNames[DateTime.Now.Month];
>
>
> On Mon, 31 Jul 2006 10:55:01 +0200, Edwin Knoppert
> wrote:
>
>> I can't find a way to obtain the months name from a date.
>> Like 'August'
>>
>>
>
>
>
> --
> Happy Coding!
> Morten Wennevik [C# MVP]
>

Re: Get month name?

am 31.07.2006 13:02:52 von Edwin Knoppert

Warning, odd the items list starts from 0 but has a 13th item..

This is actually the current month!
sMaand =
DateTimeFormatInfo.CurrentInfo.MonthNames[DateTime.Now.AddMo nths(-1).Month];



"Edwin Knoppert" schreef in bericht
news:44cdd65e$0$2021$ba620dc5@text.nova.planet.nl...
> Thanks it works however, how to use it without the culture thing?
> My web.config already has the dutch culture.
>
> DateTimeFormatInfo d = new CultureInfo("nl-NL", false).DateTimeFormat;
> sVorigeMaand = d.MonthNames[DateTime.Now.AddMonths(-1).Month];
>
> :)
>
>
> "Morten Wennevik" schreef in bericht
> news:op.tdjri5x9klbvpo@tr024.bouvet.no...
> Hi Edwin,
>
> System.Globalization.DateTimeFormatInfo d = new
> System.Globalization.DateTimeFormatInfo();
>
> string month = d.MonthNames[DateTime.Now.Month];
>
>
> On Mon, 31 Jul 2006 10:55:01 +0200, Edwin Knoppert
> wrote:
>
>> I can't find a way to obtain the months name from a date.
>> Like 'August'
>>
>>
>
>
>
> --
> Happy Coding!
> Morten Wennevik [C# MVP]
>

Re: Get month name?

am 31.07.2006 13:10:00 von Mark Rae

"Edwin Knoppert" wrote in message
news:44cdd65e$0$2021$ba620dc5@text.nova.planet.nl...

> DateTimeFormatInfo d = new CultureInfo("nl-NL", false).DateTimeFormat;
This is unnecessary in this instance...

> sVorigeMaand = d.MonthNames[DateTime.Now.AddMonths(-1).Month];
sVorigeMaand = DateTime.Now.AddMonths(-1).ToString("MMMM");

Re: Get month name?

am 31.07.2006 13:22:19 von Edwin Knoppert

Hah!
Before i tried M and MM but failed :)


"Mark Rae" schreef in bericht
news:e2XBeHJtGHA.372@TK2MSFTNGP06.phx.gbl...
> "Edwin Knoppert" wrote in message
> news:44cdd65e$0$2021$ba620dc5@text.nova.planet.nl...
>
>> DateTimeFormatInfo d = new CultureInfo("nl-NL", false).DateTimeFormat;
> This is unnecessary in this instance...
>
>> sVorigeMaand = d.MonthNames[DateTime.Now.AddMonths(-1).Month];
> sVorigeMaand = DateTime.Now.AddMonths(-1).ToString("MMMM");
>