Home All Groups Group Topic Archive Search About

Get day name given year, month and day number

Author
24 Aug 2006 7:47 PM
Stupid48
Hmm.

Is there a way to get the day name (ie Monday) given a year, month and
day number?

Thanks,

Chris

Author
24 Aug 2006 9:09 PM
Jon Meyer
You could do something like.

create your date

DateTime date = DateTime.Parse("08/24/2006");

string dateString = date.ToLongDateString();

dateString will contain the day name and you should be able to parse it out
of there.

-Jon


Show quote
"Stupid48" <cf_r***@hotmail.com> wrote in message
news:1156448859.077153.145110@m73g2000cwd.googlegroups.com...
> Hmm.
>
> Is there a way to get the day name (ie Monday) given a year, month and
> day number?
>
> Thanks,
>
> Chris
>
Author
25 Aug 2006 2:06 AM
Carl Daniel [VC++ MVP]
Stupid48 wrote:
> Hmm.
>
> Is there a way to get the day name (ie Monday) given a year, month and
> day number?

using System;
using System.Globalization;

// ...

DateTime dt = new DateTime(year,month.day);

DayOfWeek dow = dt.DayOfWeek;    // DayOfWeek is an enum

// To get the localized day name...
DateTimeFormatInfo dfi = CultureInfo.CurrentCulture;
string dayName = dfi.DayNames[dow];


-cd

AddThis Social Bookmark Button