<?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 Proc SQL inserting dates issue in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/401288#M25772</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having some trouble with dates &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to update a database table but the dates keep getting scrambled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my dataset has dates in the format IS8601DA10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a table using&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 MIWrite.table5
AS SELECT * FROM desktop.table;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this creates datetimes in my database but seems to work as the dateelement is correct so I was happy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I try to insert new values using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
INSERT INTO MIWrite.Table5
SELECT 	*
FROM Desktop.table;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the new dates show&amp;nbsp;along the lines of 1959-12-31 23:50:41.000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to change the formats of the columns in both the database structure and via SAS code but not able to resolve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cant figure out why it works when creating but not when updating &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas, database is MS sql Server&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2017 11:38:09 GMT</pubDate>
    <dc:creator>itchyeyeballs</dc:creator>
    <dc:date>2017-10-05T11:38:09Z</dc:date>
    <item>
      <title>Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/401288#M25772</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having some trouble with dates &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to update a database table but the dates keep getting scrambled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my dataset has dates in the format IS8601DA10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a table using&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 MIWrite.table5
AS SELECT * FROM desktop.table;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this creates datetimes in my database but seems to work as the dateelement is correct so I was happy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I try to insert new values using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
INSERT INTO MIWrite.Table5
SELECT 	*
FROM Desktop.table;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the new dates show&amp;nbsp;along the lines of 1959-12-31 23:50:41.000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to change the formats of the columns in both the database structure and via SAS code but not able to resolve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cant figure out why it works when creating but not when updating &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas, database is MS sql Server&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 11:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/401288#M25772</guid>
      <dc:creator>itchyeyeballs</dc:creator>
      <dc:date>2017-10-05T11:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/401331#M25781</link>
      <description>&lt;P&gt;Create an intermediary table in the SQL server and insert there, best by using pass-through SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 13:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/401331#M25781</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-05T13:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/401362#M25784</link>
      <description>&lt;P&gt;Try to format the datetime variables in Desktop.table with datetime32. format.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/401362#M25784</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-10-05T14:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402109#M25826</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the tips, I tried to play with both but struggled to get it working, ended up using "put" to covert to text format which is not ideal but better than where I was.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still can't understand why creating the table using the SAS data set worked fine but then inserting from the same data&amp;nbsp;set (after refreshing) fell over, guess its some kind of SAS vs MS interoperability thing.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Oct 2017 18:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402109#M25826</guid>
      <dc:creator>itchyeyeballs</dc:creator>
      <dc:date>2017-10-07T18:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402211#M25827</link>
      <description>&lt;P&gt;I do this myself a lot and as long the date variable is defined as a SAS DATETIME with a format of DATETIME22.2 then I've not had any problems. How is your date variable defined in your SAS table?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 19:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402211#M25827</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-10-08T19:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402212#M25828</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The initial data source is an xml file, my map file has (as an example - mostly was auto generated)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;        &amp;lt;COLUMN name="BIRTHDTE"&amp;gt;
            &amp;lt;PATH syntax="XPath"&amp;gt;/StaffRecord/Institution/Person/BIRTHDTE&amp;lt;/PATH&amp;gt;
            &amp;lt;TYPE&amp;gt;numeric&amp;lt;/TYPE&amp;gt;
            &amp;lt;DATATYPE&amp;gt;date&amp;lt;/DATATYPE&amp;gt;
            &amp;lt;FORMAT width="10"&amp;gt;IS8601DA&amp;lt;/FORMAT&amp;gt;
            &amp;lt;INFORMAT width="10"&amp;gt;IS8601DA&amp;lt;/INFORMAT&amp;gt;
        &amp;lt;/COLUMN&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Not sure why but running the create table statement using that source produces a date/time output in my sql server database.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 19:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402212#M25828</guid>
      <dc:creator>itchyeyeballs</dc:creator>
      <dc:date>2017-10-08T19:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402216#M25829</link>
      <description>&lt;P&gt;Please run this and post the output. This will describe how your SAS data is defined:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data = desktop.table;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Oct 2017 19:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402216#M25829</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-10-08T19:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402220#M25830</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample attached&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.GIF" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15700iE1103472A75AB393/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.GIF" alt="Capture.GIF" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 20:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/402220#M25830</guid>
      <dc:creator>itchyeyeballs</dc:creator>
      <dc:date>2017-10-08T20:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting dates issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/403801#M25912</link>
      <description>&lt;P&gt;I suggest you convert BIRTHDTE from DATE to DATETIME:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;birthdte = dhms(birthdte, 0, 0, 0);
format birthdte datetime 22.2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;and try inserting that.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 05:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-SQL-inserting-dates-issue/m-p/403801#M25912</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-10-13T05:39:58Z</dc:date>
    </item>
  </channel>
</rss>

