How to get the 1st and last days of the Last week

Hey Forum,

I have a process , in which i need the first and last days of the last week. For example, if the process is running on 29.08.2022 then i need to get the period 22.08.2022 and 28.08.2022. How can i get that ? Please help

Best Regards
Anit

Hey @anit.michael1,

EndDate = Today.AddDay(-1)
StartDate = Today.AddDay(-7)

Thanks,
Sanjit

1 Like

HI,

How about the following expression?

targetDate = New Date(2022,8,29)

Then

targetDate.AddDays({-7,-1,-2,-3,-4,-5,-6}(CInt(targetDate.DayOfWeek))).ToString("dd.MM.yyyy")

targetDate.AddDays({-13,-7,-8,-9,-10,-11,-12}(CInt(targetDate.DayOfWeek))).ToString("dd.MM.yyyy")

Regards,

1 Like

It’s very easy; all you have to do is define the date range by adding the beginning and ending dates, and you’re good to go. If you follow these steps, you will no longer have an issue.

1 Like

Thank you for replying. I would like to have the First and Last day of Last week. So if the process runs today, then the FirstDayOfLastWeek =22.08.2022 and FirstDayOfLastWeek= 28.08.2022.

1 Like

Hi @anit.michael1

How about this expression?

Start Date is 22.08.2022

FirstDayOfLastWeek  = Today.now.AddDays(-((now.DayOfWeek - System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek + 6) Mod 7)-7).Date

Last Date is 28.08.2022

FirstDayOfLastWeek = Today.AddDays(8 - Weekday(Today)-7)

image

Regards
Gokul

Hey @anit.michael1,

You want the last and first day of the week from the day when process is running.
For example if you are running the process today means 01-09-2022, you want the first and last from 01-09-2022?

Thanks,
Sanjit

1 Like

Hello @anit.michael1 , Welcome to Uipath Commubity
Try this , use Modify date activity. Its may helps you.
image

2 Likes

Hello

You can usemodify date activity to achieve this.

How to Modify Date in UiPath? Modify Date activity explained with demo

2 Likes

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