How do i get the previous week date Interval (Sunday to Saturday)?

hello

My question is if our current week is (24/03/2024(Sunday) to 30/03/2024(Saturday)).

When the BOT runs on any day of the current week, it should select the date range of the previous week.

previous week is (17/03/2024(Sunday) to 23/03/2024(Saturday)). this should be selected.

How can I accomplish this task with the best possible outcome?

Thanks

Hi @kishan.savaliya

Try this

startOfWeek=Now.AddDays(-CInt(Now.DayOfWeek) - 7).ToString("dd/MM/yyyy")

EndOfWeek=Now.AddDays(-CInt(Now.DayOfWeek) - 1).ToString("dd/MM/yyyy")

Cheers!!

2 Likes

Hello Kishan ji,

I made a flow for you. Please have a look hope it will help you out.
Forum_Date.zip (2.5 KB)

Please let me know if issue resolves.
Happy Automation!!

Jai shri Krishna.

Hi @kishan.savaliya

You can use this single syntax:

WeekDate = Now.AddDays(-CInt(Now.DayOfWeek) - 7).ToString("dd/MM/yyyy") + " - " + Now.AddDays(-CInt(Now.DayOfWeek) - 1).ToString("dd/MM/yyyy")

Regards

@vrdabberu @lrtetala

Thank you so much for the Solution it works absolutely Fine.

Will running the process tomorrow (30/03/2024), will it pick the previous week’s date interval?

Hi @kishan.savaliya,

We can do that by subtracting 7 from any day of the current week and thereby taking Sunday of that week, similarly Saturday of the same previous week. Hope this helps. Below is the workflow developed for you. Hope this will resolve your challenge. Also you choose the duration between any of the two days in the workflow by just modifying the Day of the week.

Past Week dates.xaml (7.7 KB)

Cheers,
Rama Krishna Dokina

1 Like

Yes @kishan.savaliya

Absolutely, It will take previous week’s interval

1 Like

Hi @kishan.savaliya

It will work for previous week as well.

Regards

1 Like

Thank You So Much @lrtetala @vrdabberu @Rama_Krishna_Dokina @hrishikesh.k

3 Likes

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