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

1 Like

@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 :
https://o7planning.org/en/10457/csharp-date-time-tutorial

1 Like

thank you @supermanPunch

1 Like