How to find the date that gives Monday next week

Hi all,

I need to create a datetime variable that gives me date of monday next week.

For example when i run this, it should give me 16.03.2020.

Thanks,

1 Like

StringVariable=DateTime.Now.AddDays(+7).AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek.Monday)) mod 7).Date.ToString()
try this
@mazlumkacar

1 Like

well, if you need the same format you can try this

  • DateTime.Now.AddDays(+7).AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek.Monday)) mod 7).Date.ToString(“dd.MM.yyyy”)

and let me know if this works
for me it’s working fine!

image

cheers @mazlumkacar

3 Likes

@mazlumkacar Check this :
now.AddDays((now.DayOfWeek * -1)+8).ToString(“dd.MM.yyyy”)

If this works, Check it tomorrow as well, If it Works Tomorrow, Then it should work Always :sweat_smile:

1 Like

hi @supermanPunch how to learn this syntax ?
where can i learn is there any video available or documentaions?

@Jebarohith19 It’s Just Experimenting with trial and error methods :sweat_smile: . But we need to have basic Knowledge, and that basic knowledge can be found in many tutorials in the web. One Such tutorial I have mentioned below :

1 Like

thank you @supermanPunch

1 Like

Hey there,
sorry to bump this old thread. I’ve tried this solution, and it worked for every day of the week except Sunday. On Sunday, I get dayofweek=0. So (0*-1)+8=8 which gives me the Monday after the one I want.
Am I missing something obvious here?
Best regards,
Jeroen

How to give day(Monday) dynamically

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.