<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Getting the first day of the week of any week.</title><link>https://community.appian.com/discussions/f/rules/21706/getting-the-first-day-of-the-week-of-any-week</link><description>Hi all, this is a problem that&amp;#39;s been troubling me for some time. 
 Let&amp;#39;s say that I have the following date, &amp;quot;08/18/2021&amp;quot;. I know that it falls on a wednesday, and I want to substract enough days in order to get &amp;quot; 08/16/2021&amp;quot; as the result. Same for</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Getting the first day of the week of any week.</title><link>https://community.appian.com/thread/84881?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 15:12:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:09cdd35f-36df-411c-895d-dbe4ff8ceaf0</guid><dc:creator>Arturo Garc&amp;#237;a</dc:creator><description>&lt;p&gt;Thanks, Chris! The weekday() function indeed is super helpful.&lt;/p&gt;
&lt;p&gt;The issue in my code apparently was in the datetext() function. It subtracted an extra day, and I didn&amp;#39;t know until I looked at the code with fresh eyes, and decided to use text() instead.&lt;/p&gt;
&lt;p&gt;It ended up like this, and it works great. It always returns the Monday of the week in question&amp;nbsp;&lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;a!localVariables(&lt;br /&gt; local!ctrlday: todate(&amp;quot;08/25/2021&amp;quot;),&lt;br /&gt; local!daysDiff: weekday(local!ctrlday) - 2,&lt;br /&gt; local!endResult: local!ctrlday - (local!daysDiff),&lt;br /&gt; {&lt;br /&gt; &amp;quot;Date: &amp;quot; &amp;amp; local!ctrlday &amp;amp; &amp;quot;. Weekday: &amp;quot; &amp;amp; weekday(local!ctrlday),&lt;br /&gt; local!daysDiff,&lt;br /&gt; text(local!endResult, &amp;quot;yyyy/MM/dd&amp;quot;)&lt;br /&gt; }&lt;br /&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting the first day of the week of any week.</title><link>https://community.appian.com/thread/84880?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 15:06:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b7fdbef6-3d10-44de-8c6d-54176554d179</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Hi Gabriel, the weekday() function is great in this scenario:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;ri!date-weekday(ri!date)+2&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>