I want to know a specific date belongs to which day [Resolved]

Posted by Amritha444 under C# on 1/6/2011 | Points: 10 | Views : 1334 | Status : [Member] | Replies : 5
Dear all

I want to know a specific date belongs to which day

For eg:

i want to know 23-01-2010 is monday,tuesday...how to check it?




Responses

Posted by: Madhuk on: 1/6/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
DateTime dt = Convert.ToDateTime("01-23-2010");
Response.Write(dt.DayOfWeek.ToString());

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Eswarreddy on: 1/6/2011 [Member] Starter | Points: 25

Up
0
Down

Try this Snippet. It works & might be helpful.


string date = "23-01-2010";
DateTime dt = new DateTime();
dt =DateTime.ParseExact(date,"dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);
string day = dt.DayOfWeek.ToString();


For your sample date, string day='Saturday' is the output.


Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sankkrit on: 1/7/2011 [Member] Starter | Points: 25

Up
0
Down
This will help you to get know

string str = "23-01-2010";
Datetime dt = Convert.TodateTime(str);
string str dayOfweek = dt.DayOfWeek.ToSting();

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/7/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Use this library, you have a consolidated list of all date manipulations available here and easy to use as well

http://www.codeproject.com/KB/cs/csdatetimelibrary.aspx

Thanks
Karthik
www.f5Debug.net

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Suresh.mekkattil on: 1/9/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

You can use the DateTime.DayOfWeek.ToString(). to resolve this problem.



-----
Suresh M

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response