Solved

# c#, Exsplorer 7

Posted on 2007-08-07
Medium Priority
283 Views
i need to get the name of the day from the date for exsample :  06/07/2007 i need to get
monday

and also i need the number of days from the month for exs :
07/2007 is 31 days .

thanks ....
0
Question by:Tech_Men
• 3
• 3

LVL 11

Assisted Solution

udhayakumard earned 400 total points
ID: 19644154
Hi,

Try this....

DateTime dt = DateTime.Parse("06/07/2007");

MessageBox.Show(dt.DayOfWeek.ToString());
0

LVL 15

Accepted Solution

angus_young_acdc earned 1600 total points
ID: 19644163
Hi Tech Men,

DateTime.Now - this will give you the date and time
DateTime.Today.DayOfWeek - this will give you the day
DateTime.DaysInMonth([insert year], [insert month]); - this will give you how many days in a month

I hope this helps
0

LVL 11

Expert Comment

ID: 19644292
Hi,

For the second question try this.....

CultureInfo ci = new CultureInfo("en-US");

ci.Calendar.GetDaysInMonth(2007, 08);

MessageBox.Show(ci.Calendar.GetDaysInMonth(2007, 02).ToString());
0

LVL 11

Expert Comment

ID: 19644304
Hi,

DateTime dt = DateTime.Parse("08/06/2007");
MessageBox.Show(dt.DayOfWeek.ToString());
MessageBox.Show(DateTime.DaysInMonth(08, 2007).ToString());

0

LVL 15

Assisted Solution

angus_young_acdc earned 1600 total points
ID: 19644328
DateTime.DaysInMonth([insert year], [insert month]) is the same :)
0

LVL 15

Assisted Solution

angus_young_acdc earned 1600 total points
ID: 19644359
Silly submit button being clicked before I wanted!

Anyway, I should have said that the best way to get the days in a month without hardcoding it (which becomes outdated after a month unless you re-do it and re-compile) is to go:

Console.WriteLine("Days In Month: {0}", DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month));

That auto inputs year and month
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
###### Suggested Courses
Course of the Month13 days, 14 hours left to enroll