<?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: problem with trunc SQL in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574475#M162335</link>
    <description>&lt;P&gt;PS trunc() is a special function in SAS that reduces the length of the &lt;EM&gt;binary&lt;/EM&gt; representation of numbers (which means that the values remain mostly unchanged aside from a loss in precision).&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 07:49:58 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-07-18T07:49:58Z</dc:date>
    <item>
      <title>problem with trunc SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574472#M162332</link>
      <description>&lt;P&gt;I have the following&amp;nbsp; Oracle SQL:&lt;/P&gt;&lt;P&gt;select count(*) from my_table where trunc(timestamp) = trunc(sysdate);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have lib to the database and created following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select count(*) from Libma.my_table where trunc(timestamp) = trunc(sysdate);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How I figured out trunc works different in SAS but what is best solution to get the same result as in Oracle SQL.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 07:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574472#M162332</guid>
      <dc:creator>DataExplorer</dc:creator>
      <dc:date>2019-07-18T07:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: problem with trunc SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574474#M162334</link>
      <description>&lt;P&gt;What are the contents of the columns?&lt;/P&gt;
&lt;P&gt;Oracle trunc() is a function that retrieves the date out of a date, since (IIRC) Oracle dates can also contain times (similar to Excel, where datetimes are stored as counts of days, with the time in the fractional part).&lt;/P&gt;
&lt;P&gt;So what you are looking for in SAS is the datepart() function if you need to retrieve the date from a datetime (as in SAS dates are counts of days, and times counts of seconds, so datetime = 86400 * date). But you need to take care that you don't apply datepart() to something that is already a date when imported into SAS by the oracle engine.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 07:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574474#M162334</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-18T07:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: problem with trunc SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574475#M162335</link>
      <description>&lt;P&gt;PS trunc() is a special function in SAS that reduces the length of the &lt;EM&gt;binary&lt;/EM&gt; representation of numbers (which means that the values remain mostly unchanged aside from a loss in precision).&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 07:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574475#M162335</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-18T07:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: problem with trunc SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574513#M162354</link>
      <description>&lt;P&gt;Ok&amp;nbsp; i tried the following Code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where datepart(zeitstempel) = today();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seem to work but no matches in the database so I tried the following code for a test:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where datepart(zeitstempel) = datepart(timestamp '2018-08-08 18:50:07');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I get this error&lt;/P&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;33         where datepart(mytimestamp) = datepart(timestamp '2018-08-08 18:50:07');

                                                          _____________________

                                                          22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, CONTAINS,

              EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what the problem ist.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 10:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-trunc-SQL-in-SAS/m-p/574513#M162354</guid>
      <dc:creator>DataExplorer</dc:creator>
      <dc:date>2019-07-18T10:56:57Z</dc:date>
    </item>
  </channel>
</rss>

