How to get the last Sunday date

0
Hey everyone, I have requirement to display the last Sunday date from current date. example - If today is Monday, 11/27/2023, then I required the 11/26/2023. can anyone help me on the logic for this.  
asked
2 answers
1

Hi Rishabh,

By using this function you can get the Last Sunday

image.png

answered
1

This should work for all locales.

 

Screenshot 2023-11-29 at 20.35.14.png

 

addDays([%BeginOfCurrentDay%],-parseInteger(formatDateTime([%BeginOfCurrentDay%],'u')))

 

Here we use the formatDateTime function with a format of 'u'. This returns the day of the week numerically, with 1 being Monday, through to 7 being Sunday. We then convert this to an integer using the parseInteger function, and subtract it from the current date to get previous Sunday.

 

https://docs.mendix.com/refguide/parse-and-format-date-function-calls/#1-introduction

 

I hope this helps.

answered