Click here to Skip to main content
16,017,745 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
How to get the day of present day in c#
Posted
Updated 3-Dec-10 7:52am
v2

DateTime.Now.Day or DateTime.Now.DayOfWeek, depending of what you mean by day (2 or Thursday)...
 
Share this answer
 
v2
Use DayOfWeek property of DateTime.

Try:
C#
DateTime dt = new DateTime(); 
Console.WriteLine("The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek); 
// Outputs: The day of the week for 12/2/2010 is Thursday.

Here [^]you go to see all available properties of DateTime and what they provide.
 
Share this answer
 
v2
It's really quite simple to do in C# thankfully. :)

using System;

DateTime today = DateTime.Today;
 
Share this answer
 
v2
DateTime.Today(To get the date)
DateTime.Now(To get the the date with time)
 
Share this answer
 
Try:

DateTime todayDate = DateTime.Today;
int todayYear = todayDate.Year;
int todayMonth = todayDate.Month;
int todayDay = todayDate.Day;


I hope it is useful.
[snip]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900