<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Extract Recent Past Saturday in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Extract-Recent-Past-Saturday/m-p/334783#M231889</link>
    <description>&lt;P&gt;Hello Guys,&lt;/P&gt;&lt;P&gt;How to Extract recent past Saturday based on today date and is there any expression language to get by update attribute&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jan 2022 17:56:51 GMT</pubDate>
    <dc:creator>sachin_32</dc:creator>
    <dc:date>2022-01-28T17:56:51Z</dc:date>
    <item>
      <title>Extract Recent Past Saturday</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Extract-Recent-Past-Saturday/m-p/334783#M231889</link>
      <description>&lt;P&gt;Hello Guys,&lt;/P&gt;&lt;P&gt;How to Extract recent past Saturday based on today date and is there any expression language to get by update attribute&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 17:56:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Extract-Recent-Past-Saturday/m-p/334783#M231889</guid>
      <dc:creator>sachin_32</dc:creator>
      <dc:date>2022-01-28T17:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Recent Past Saturday</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Extract-Recent-Past-Saturday/m-p/338247#M232779</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/94673"&gt;@sachin_32&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You can accomplish by utilizing the "Advanced UI" capability found in the &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-update-attribute-nar/1.15.3/org.apache.nifi.processors.attributes.UpdateAttribute/index.html" target="_self"&gt;UpdateAttribute&lt;/A&gt; processor.&lt;BR /&gt;&lt;BR /&gt;The advanced UI allows you to create Rules (think if these as an IF/Then capability).&lt;BR /&gt;So you would setup 3 rules:&lt;BR /&gt;1. If current date falls on Mon - Fri, do X&lt;BR /&gt;2. if current date falls on Sat, do nothing&lt;/P&gt;&lt;P&gt;3. if current date falls on Sun, do Y&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html" target="_self"&gt;Expression Language guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Below you can see I have created 3 rules (Day1-5, Day6, and Day7)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1646853075404.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/33914i4017900D7390950A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_0-1646853075404.png" alt="MattWho_0-1646853075404.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Once you create a Rule, you need to provide a Condition (This is your boolean if statement)&lt;/P&gt;&lt;P&gt;In this case I am using it to figure out what the current day of the week with 1= Monday and 7 = Sunday and seeing if the day of the week is prior to Sat or after Sat in the current week.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If a rules condition (if statement) resolves to a boolean "true", then the configured "Actions" (then statement) are evaluated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;For my "Day1-5" rule, I set:&lt;BR /&gt;Condition:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${now():format('u'):lt(6)}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Action:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${now():toNumber():minus(${now():format('u'):plus(1):multiply(86400000)}):toDate():format("EEE, dd MMM yyyy")}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For my "Day6" rule, I set:&lt;/P&gt;&lt;P&gt;Condition:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${now():format('u'):equals(6)}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Action:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${now():format('EEE, dd MMM yyyy')}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my "Day7" rule, I set:&lt;/P&gt;&lt;P&gt;Condition:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${now():format('u'):gt(6)}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Action:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;${now():toNumber():minus(86400000):toDate():format("EEE, dd MMM yyyy")}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;About above:&lt;BR /&gt;- The "now()" function returns the current date.&lt;/P&gt;&lt;P&gt;- 86400000 is the number of milliseconds in 1 day.&lt;BR /&gt;- So first I get the current date and convert it to milliseconds using the "toNumber()" function.&lt;BR /&gt;- Then for Day1-5, I am subtracting based on current day of week a multiple of days worth of milliseconds.&lt;BR /&gt;- For Day6, I am doing nothing other than reformatting the current days date.&lt;BR /&gt;- For Day7, I am just subtracting one day or 86400000 milliseconds&lt;BR /&gt;&lt;BR /&gt;No matter which rule is applied the final date format i choose to write to an attribute named "PreviousSaturday" on the FlowFile is formatted using &lt;A href="https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html" target="_self"&gt;java simple date&lt;/A&gt; format "EEE, dd MMM yyyy"&lt;BR /&gt;Example: "&lt;SPAN&gt;Sat, 05 Mar 2022"&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you found this response assisted with your query, please take a moment to login and click on "&lt;STRONG&gt;Accept as Solution&lt;/STRONG&gt;" below this post.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 19:30:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Extract-Recent-Past-Saturday/m-p/338247#M232779</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2022-03-09T19:30:33Z</dc:date>
    </item>
  </channel>
</rss>

