<?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>topic Re: How to know if a date falls between two dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639668#M190341</link>
    <description>&lt;P&gt;The condition would be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if start_date le '30apr2020'd and end_date ge '01apr2020'd&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Apr 2020 08:52:54 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-04-14T08:52:54Z</dc:date>
    <item>
      <title>How to know if a date falls between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639662#M190337</link>
      <description>Hello&lt;BR /&gt;I have a data with two dates, start_date and end_date. If any day in Apr2020 falls between those two dates, then I will create a new variable with value=‘Y’ else value=‘N’. I know it looks easy but I have no idea how to code this. &lt;BR /&gt;I’m thinking:&lt;BR /&gt;Data want: set have:&lt;BR /&gt;If AnyDayInApril2020 between start_date and end_date then value =‘Y’ else value=‘N’; run;&lt;BR /&gt;How do I consider the whole month of April into the code? It doesn’t have to be the entire month. As long as a day in Aprl, ex 12Apr2020 is between the two dates then it is valid. &lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Apr 2020 08:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639662#M190337</guid>
      <dc:creator>JT99</dc:creator>
      <dc:date>2020-04-14T08:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date falls between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639664#M190339</link>
      <description>could you please provide a sample data with expected output to help you</description>
      <pubDate>Tue, 14 Apr 2020 08:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639664#M190339</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-04-14T08:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date falls between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639668#M190341</link>
      <description>&lt;P&gt;The condition would be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if start_date le '30apr2020'd and end_date ge '01apr2020'd&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2020 08:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639668#M190341</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-14T08:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date falls between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639669#M190342</link>
      <description>Thank you so much for this solution! I feel bad I never thought of this. Thanks again!</description>
      <pubDate>Tue, 14 Apr 2020 09:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639669#M190342</guid>
      <dc:creator>JT99</dc:creator>
      <dc:date>2020-04-14T09:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to know if a date falls between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639670#M190343</link>
      <description>&lt;P&gt;It is always good to look at the inverse of a problem; in this case "which individual conditions for the dates would make it impossible for the range to contain a day of April 2020?"&lt;/P&gt;
&lt;P&gt;This results in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if start_date gt '30apr2020'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if end_dt lt '01apr2020'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since either would invalidate the whole condition, we use "or":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if start_date gt '30apr2020'd or end_dt lt '01apr2020'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then we apply some Boolean logic: to invert a compound condition (two conditions connected with AND or OR), you invert the individual parts and convert the logical operator to its opposite; that results in the solution you accepted.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 09:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-if-a-date-falls-between-two-dates/m-p/639670#M190343</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-14T09:20:35Z</dc:date>
    </item>
  </channel>
</rss>

