
Recently, I needed to run some date calculations in Liquid to detect what the start date (Sunday) or end date (Saturday) of the current week is, and I found there was no trivial filter in Power Pages’ Liquid for that.
But by doing some data manipulation, we can achieve that.
The basics
The date filter accepts Custom Date and Time Format strings as a parameter (same as in .net).
Looking at the documentation, we can see two options that can be used for handling the current weekday:
We can use either the “ddd” or “dddd” to detect what is the current weekday and do some logic on it.
The liquid code
Based on this option, I’ve put together the following Liquid code that:
The console.log statement is added only to help with debugging values, but use the variables as needed:
{% assign today_name = now | date: "dddd" %}
{% assign weekday_num = 0 %}
{% case today_name %}
{% when "Sunday" %}{% assign weekday_num = 0 %}
{% when "Monday" %}{% assign weekday_num = 1 %}
{% when "Tuesday" %}{% assign weekday_num = 2 %}
{% when "Wednesday" %}{% assign weekday_num = 3 %}
{% when "Thursday" %}{% assign weekday_num = 4 %}
{% when "Friday" %}{% assign weekday_num = 5 %}
{% when "Saturday" %}{% assign weekday_num = 6 %}
{% endcase %}
{%comment%} Move BACK to this week's Sunday{%endcomment%}
{% assign offsetToSunday = weekday_num | times: -1 %}
{% assign sunday = now | date_add_days: offsetToSunday %}
{%comment%} Saturday is 6 days after Sunday{%endcomment%}
{% assign saturday = sunday | date_add_days: 6 %}
<script>
console.log(`This Sunday: {{ sunday | date: "yyyy-MM-dd" }}`);
console.log(`This Saturday: {{ saturday | date: "yyyy-MM-dd" }}`);
</script>
Conclusion
Power Pages Liquid doesn’t have built-in filters to directly get the start or end of the week, but by using .NET-style date formats (ddd or dddd) to find the current weekday and mapping it to a number, we can calculate the offset to Sunday and Saturday easily.
Hope this post helps in case you come across similar need.
References
Custom date and time format strings – Microsoft Learn
Available Liquid Filters – Date Filters – Microsoft Learn
The post How to Find Sunday and Saturday of the Current Week Using Liquid in Power Pages appeared first on michelcarlo.
Original Post https://michelcarlo.com/2025/11/01/how-to-find-sunday-and-saturday-of-the-current-week-using-liquid-in-power-pages/






