Forum Discussion
Column with Date.EndOfWeek for last week
Hello everybody!
I need to add a column with the end date for the last week.
The following M-Code formats the end of week based on a date:
Date.EndOfWeek(#date(2011, 5, 14))
How can be this transferred for the last week?
You can use Date.StartOfWeek, or subtract the desired number of days from that expression (e.g., -7).
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
Hi joshua1990 ,
You could refer to mahoneypat ' suggestion , use Date.StartOfWeek(Date.From(DateTime.LocalNow())) to get start day of current week, then you could -1 to get the end day of last week by below code
= Date.AddDays(Date.StartOfWeek(Date.From(DateTime.LocalNow())),-1)Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 Replies
- Greg_DecklerCommunity ChampionDate.EndOfWeek(#date(2011, 5, 14 - 7))
?- joshua1990Post Prodigy
Thanks!
But I need a dynamic function for the last week.
It should be not fixed for just one week.
I need after every refresh (once a week) the end for the corresponding week.
- mahoneypatMicrosoft Employee
To do it in query, use Date.EndOfWeek(Date.From(DateTime.LocalNow()))
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
- joshua1990Post Prodigy
Thanks! And how can I reference to last week? This will me show the current week.
- mahoneypatMicrosoft Employee
You can use Date.StartOfWeek, or subtract the desired number of days from that expression (e.g., -7).
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat