<?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: Filter data based on current weekday in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786160#M32185</link>
    <description>&lt;P&gt;In other parts of your query, you use the DATEPART function on ACTIVATION_DATE, suggesting that it is in fact a datetime value; therefore, comparing it to a date value will fail.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Dec 2021 12:57:59 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-12-15T12:57:59Z</dc:date>
    <item>
      <title>Filter data based on current weekday</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786153#M32184</link>
      <description>&lt;P&gt;I'm trying to do a smart filter where it filter the last 3 days when it works on Sunday and it filter the last 2 days when it works on any other day but it gives me empty output always&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.QUERY_FOR_BILLING_CONTRACTS_DETA AS&lt;BR /&gt;SELECT t1.PROCESS_DATE,&lt;BR /&gt;t1.CUST_NUMBER,&lt;BR /&gt;t1.CUSTCODE,&lt;BR /&gt;t1.CONTRACT_TYPE,&lt;BR /&gt;t1.SUB_MARKET,&lt;BR /&gt;t1.TITLE,&lt;BR /&gt;t1.F_NAME,&lt;BR /&gt;t1.M_NAME1,&lt;BR /&gt;t1.M_NAME2,&lt;BR /&gt;t1.L_NAME,&lt;BR /&gt;t1.M_NAME_AS_IS,&lt;BR /&gt;t1.NATIONALITY,&lt;BR /&gt;t1.ID_TYPE,&lt;BR /&gt;t1.ID_NUMBER,&lt;BR /&gt;t1.NATIONAL_NUMBER,&lt;BR /&gt;t1.SUBS_NATIONAL_NO,&lt;BR /&gt;t1.COMPANY_RGT_NO,&lt;BR /&gt;t1.GENDER,&lt;BR /&gt;t1.BIRTHDATE,&lt;BR /&gt;t1.PO_BOX,&lt;BR /&gt;t1.CCZIP,&lt;BR /&gt;t1.ALTERNATIVE_NO1,&lt;BR /&gt;t1.ALTERNATIVE_NO2,&lt;BR /&gt;t1.CCEMAIL,&lt;BR /&gt;t1.CCADDR2,&lt;BR /&gt;t1.CCADDR3,&lt;BR /&gt;t1.GOVERNORATE,&lt;BR /&gt;t1.CCCITY,&lt;BR /&gt;t1.AREA,&lt;BR /&gt;t1.BILLCYCLE,&lt;BR /&gt;t1.ACCOUNT_TYPE,&lt;BR /&gt;t1.MSISDN,&lt;BR /&gt;t1.CO_ID,&lt;BR /&gt;t1.PACKAGE_NAME,&lt;BR /&gt;t1.CONTRACT_NUMBER,&lt;BR /&gt;t1.CUSTOMER_ACTIVATION_DATE,&lt;BR /&gt;t1.ACTIVATION_DATE,&lt;BR /&gt;t1.CONTRACT_CHANNEL_TYPE,&lt;BR /&gt;t1.CONTRACT_CHANNEL_DESC,&lt;BR /&gt;t1.USER_NAME,&lt;BR /&gt;t1.CREDIT_CATEGORY,&lt;BR /&gt;t1.PACKAGE_MARKET,&lt;BR /&gt;/* Check */&lt;BR /&gt;(CASE&lt;BR /&gt;WHEN datepart(t1.ACTIVATION_DATE) = datepart(t1.CUSTOMER_ACTIVATION_DATE) THEN "New Customer"&lt;BR /&gt;ELSE "Old customer"&lt;BR /&gt;END) AS Check&lt;BR /&gt;FROM BI_LEB.BILLING_CONTRACTS_DETAILS t1&lt;BR /&gt;WHERE t1.CONTRACT_TYPE = 'POSTPAID' AND t1.ACCOUNT_TYPE = 'Flat Account' AND t1.CONTRACT_CHANNEL_DESC NOT =&lt;BR /&gt;'IT Support Testing' AND (CALCULATED Check) = 'New Customer' AND t1.ACTIVATION_DATE BETWEEN&lt;BR /&gt;(CASE&lt;BR /&gt;WHEN weekday(today()) = 1 THEN TODAY()-3&lt;BR /&gt;WHEN weekday(today()) &amp;gt; 1 THEN TODAY()-1&lt;BR /&gt;END)) AND today();&lt;BR /&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 12:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786153#M32184</guid>
      <dc:creator>mohtamimi94</dc:creator>
      <dc:date>2021-12-15T12:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on current weekday</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786160#M32185</link>
      <description>&lt;P&gt;In other parts of your query, you use the DATEPART function on ACTIVATION_DATE, suggesting that it is in fact a datetime value; therefore, comparing it to a date value will fail.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 12:57:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786160#M32185</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-15T12:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on current weekday</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786195#M32186</link>
      <description>&lt;P&gt;Looks like the issue is that the variable that has the name t1.ACTIVATION_DATE probably actually has DATETIME values (despite its name) instead of DATE values.&amp;nbsp; So you need to use the DATEPART() function if you want to compare its values to date values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  AND datepart(t1.ACTIVATION_DATE)
      BETWEEN (CASE WHEN weekday(today()) = 1 THEN TODAY()-3
                    WHEN weekday(today()) &amp;gt; 1 THEN TODAY()-1
               END)
      AND today()&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE WORK.QUERY_FOR_BILLING_CONTRACTS_DETA AS
SELECT
   t1.PROCESS_DATE
  ,t1.CUST_NUMBER
  ,t1.CUSTCODE
  ,t1.CONTRACT_TYPE
  ,t1.SUB_MARKET
  ,t1.TITLE
  ,t1.F_NAME
  ,t1.M_NAME1
  ,t1.M_NAME2
  ,t1.L_NAME
  ,t1.M_NAME_AS_IS
  ,t1.NATIONALITY
  ,t1.ID_TYPE
  ,t1.ID_NUMBER
  ,t1.NATIONAL_NUMBER
  ,t1.SUBS_NATIONAL_NO
  ,t1.COMPANY_RGT_NO
  ,t1.GENDER
  ,t1.BIRTHDATE
  ,t1.PO_BOX
  ,t1.CCZIP
  ,t1.ALTERNATIVE_NO1
  ,t1.ALTERNATIVE_NO2
  ,t1.CCEMAIL
  ,t1.CCADDR2
  ,t1.CCADDR3
  ,t1.GOVERNORATE
  ,t1.CCCITY
  ,t1.AREA
  ,t1.BILLCYCLE
  ,t1.ACCOUNT_TYPE
  ,t1.MSISDN
  ,t1.CO_ID
  ,t1.PACKAGE_NAME
  ,t1.CONTRACT_NUMBER
  ,t1.CUSTOMER_ACTIVATION_DATE
  ,t1.ACTIVATION_DATE
  ,t1.CONTRACT_CHANNEL_TYPE
  ,t1.CONTRACT_CHANNEL_DESC
  ,t1.USER_NAME
  ,t1.CREDIT_CATEGORY
  ,t1.PACKAGE_MARKET
  ,CASE WHEN datepart(t1.ACTIVATION_DATE) = datepart(t1.CUSTOMER_ACTIVATION_DATE) THEN "New Customer"
        ELSE "Old customer"
   END AS Check
FROM BI_LEB.BILLING_CONTRACTS_DETAILS t1
WHERE t1.CONTRACT_TYPE = 'POSTPAID'
  AND t1.ACCOUNT_TYPE = 'Flat Account'
  AND t1.CONTRACT_CHANNEL_DESC NOT = 'IT Support Testing'
  AND (CALCULATED Check) = 'New Customer'
  AND datepart(t1.ACTIVATION_DATE)
      BETWEEN (CASE WHEN weekday(today()) = 1 THEN TODAY()-3
                    WHEN weekday(today()) &amp;gt; 1 THEN TODAY()-1
               END)
      AND today()
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Dec 2021 15:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786195#M32186</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-15T15:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on current weekday</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786271#M32204</link>
      <description>&lt;P&gt;Solved, thank you&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 08:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Filter-data-based-on-current-weekday/m-p/786271#M32204</guid>
      <dc:creator>mohtamimi94</dc:creator>
      <dc:date>2021-12-16T08:25:53Z</dc:date>
    </item>
  </channel>
</rss>

