How to get the day name from a selected date?

0 votes
asked Oct 23, 2009 by angel-escobedo

I have this : Datetime.Now(); or 23/10/2009
I want this : Friday

For local date-time (GMT-5) and using Gregorian calendar.

6 Answers

0 votes
answered Oct 23, 2009 by brendan
//default locale
System.DateTime.Now.DayOfWeek.ToString();
//localized version
System.DateTime.Now.ToString("dddd");

To make the answer more complete:

0 votes
answered Oct 23, 2009 by charles-bretana
DateTime now = DateTime.Now
string s = now.DayOfWeek.ToString();
0 votes
answered Oct 23, 2009 by joseph

You're looking for the DayOfWeek property.

Here's the msdn article.

0 votes
answered Oct 23, 2009 by letterman

DateTime.Now.DayOfWeek quite easy to guess actually.

for any given date:

   DateTime dt = //....
   DayOfWeek dow = dt.DayOfWeek; //enum
   string str = dow.ToString(); //string
0 votes
answered Oct 23, 2009 by manoj-talreja

try this:

DateTime.Now.DayOfWeek
0 votes
answered Oct 28, 2015 by subrata-sarkar

What about if we use String.Format here

DateTime today = DateTime.Today;
String.Format("{0:dd-MM}, {1:dddd}", today, today) //In dd-MM format
String.Format("{0:MM-dd}, {1:dddd}", today, today) //In MM-dd format
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...