Get day name given year, month and day number

  • Thread starter Thread starter Stupid48
  • Start date Start date
S

Stupid48

Hmm.

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

Thanks,

Chris
 
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
 
Stupid48 said:
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
 
Back
Top