1) How do I find Current Week from Current Date time in C#?
2) Then we have to find given date, Is Exist on corresponding Week dates?
Pls assists to me for solve it?
1) How do I find Current Week from Current Date time in C#?
2) Then we have to find given date, Is Exist on corresponding Week dates?
Pls assists to me for solve it?
You have to use a Calendar.
Calendar cal = new Calendar();
int week = cal.GetWeekOfYear(DateTime time, calendarWeekRule rule, DayOfWeek firstDayOfWeek);
Check here: http://msdn.microsoft.com/en-us/library/system.globalization.calendar.getweekofyear(v=vs.110).aspx
To get week number of any given date:
var culture = CultureInfo.CurrentCulture;
int weekNo = culture.Calendar.GetWeekOfYear(
new DateTime(YOUR_GIVEN_DATE_HERE),
currentCulture.DateTimeFormat.CalendarWeekRule,
currentCulture.DateTimeFormat.FirstDayOfWeek);
Just replace YOUR_GIVEN_DATE_HERE with Datetime.Now (for current date) or your any given date. If the weekNos are equal then they are in the same week. That will solve both of your questions.