Work out the previous Sunday

Hi,

Is there a way I can work out the previous Sundays date. Throughout the week my automation will run and I need to be able to enter in Sundays date each time.

Thanks

How about getting DayOfWeek number by using Weekday() function (If it’s Sunday it returns 1 and if Saturday it returns 7).
Then you need just add 7 to current date when it’s Sunday, or you’ll need to add 6 if it’s Monday.

Like this:
nextSunday = Today.AddDays(8 - Weekday(Today))

With following example you can get next Sunday of any input date.

get date of next Sunday.zip (2.3 KB)

Building on what @a-Taniya has stated, if you wanted to acquire the previous Sunday’s date you could use:
Today.AddDays(- (Weekday(Today) - 1))

26/06/17 - (2 - 1) = 25/06/17

3 Likes

Thanks Mr_JDavey, I was mixed up while crafting sample flow! :sweat_smile:

1 Like

Thanks for the reply. It worked great. Thanks.

In line to the same question, how would we find out the first monday of the week?

Hi @Mr_JDavey ,
Could you please help on How to figure out the previous Friday simialarly?
If anybody knows please figure it out!

@ramees.pk easiest way without thinking about it at all would be to simply use the solution provided by @Mr_JDavey, but subtract 2. So the formula would be: Today.AddDays(- (Weekday(Today) - 1)-2)