15,610,088 members
See more:
Hello friends,

Please help me I am unable to find on net. I need to find date of particular day in a week, which means user click on Sunday then date of Sunday should display on label.

Posted
Updated 1-Feb-11 22:55pm
v2
shakil0304003 2-Feb-11 5:32am
what you tried?

## Solution 1

Did you think of this logically? A month can have 4/5 same days (for e.g. lets say sunday); how would you know that user wanted the 1st sunday or the last sunday of the month.

For sure, you need to consider more parameters like week number etc.

With the likely code:

```private DateTime GetDateBasedOnDay(string Pstrday)
{
DateTime LobjDate = null;

DateTime LobjToday = DateTime.Now.Date;
DayOfWeek LobjDayToday = LobjToday.DayOfWeek;

DayOfWeek LobjLookUpDay = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), Pstrday);

while (LobjToday.DayOfWeek != LobjLookUpDay)
{
}

LobjDate = LobjToday.Date;

return LobjDate;```
}

v2
bburhanbohra 2-Feb-11 5:13am
i just want date of next day... if user select sunday and today is monday then it show sunday's date...
Manas Bhardwaj 2-Feb-11 5:32am
Manas Bhardwaj 2-Feb-11 5:37am
JF2015 2-Feb-11 5:34am
Looks as a simple enough solution for the OP to understand it. 5+
Manas Bhardwaj 2-Feb-11 5:39am
thnks :)

## Solution 2

You can use it.
```DayOfWeek week1 = DayOfWeek.Tuesday;
int dif = week1 - DateTime.Now.DayOfWeek;
if (dif < 0)
dif += 7;

Console.WriteLine(dt);
```

bburhanbohra 2-Feb-11 6:25am
thanks...
shakil0304003 2-Feb-11 6:46am
Welcome.