How to get the date of the same day of the week on the next week

I need a little help. I have a process i am trying to automate that tracks where certain machines are serviced on time or not on a certain day of the week, bi week or month. For example if a machine was supposed to be serviced on Monday of this week and wasn’t serviced until Tuesday, i need to get the date of the next Monday to put on the spreadsheet as the next scheduled service date. Can someone help? Thanks

@lharris,

If you are checking for the Monday scheduled system on Tuesday then you can add 6 days with current date. So it will give next Monday’s date.

System.DateTime.Now.AddDays(6).Date

This will return you a datetime datatype vale you can pass it to a string value.

1 Like

Hi,

I would +7 onto the date value you have for Monday this week. Calculate the value using date.AddDays(7)

Thanks guys. The date of the scheduled service date could be any day in the week. We have the day of the week the system should be serviced in a spreadsheet beside each system. My thinking is read the sheet and get day of the week it should be serviced, it if was serviced on a Tuesday and should have been Monday then i need the next scheduled service date to be the date of the next weekday that it should have been serviced. Hope this explanation is clear.

Hi @lharris
(System.Date.today.AddDays(7).Date).ToString(“dd/MM/yyyy”)