<?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: Getting Date into Sql Server -Not Datetime in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133012#M260768</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hello esjackso1. That is correct, you have perfectly stated my problem. I am able to get datetimes into sql server, but I cannot get an actual DATE into a field of the datatype DATE, which is a problem because quite a few of our tables are using the "DATE" format (in sql).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will open a ticket with sas tech support, however I am curious if anyone at all has run into this problem before?&lt;/P&gt;&lt;P&gt;Thanks all!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Mar 2013 19:05:27 GMT</pubDate>
    <dc:creator>Anotherdream</dc:creator>
    <dc:date>2013-03-12T19:05:27Z</dc:date>
    <item>
      <title>Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133006#M260762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all. This is a very general question but I still have not been able to find the solution online.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically whenever I am insert dates into sql, I have to convert the dates into datetimes and have the values of 00:00:00 attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is, if you have a sql table with a column of "Date" format, how do you get SAS dates to insert into this field? When I try an insert option, sas throws the error "column X is not of the correct datatype". When I try to create a table, SAS converts the dates into 1960:03:00:93 (converting the date into seconds from 1960-01-01.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Brandon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 15:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133006#M260762</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-03-12T15:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133007#M260763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't help with this but you might want to describe exactly how you are connecting to the database and examples of code. Others with more experience will have more information to diagnose and help with a more concrete example of what you have attempted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 16:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133007#M260763</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-03-12T16:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133008#M260764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;Anotherdream wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Basically whenever I am insert dates into sql, I have to convert the dates into datetimes and have the values of 00:00:00 attached.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that's the answer there. Or do you need to know how to do that conversion?&lt;/P&gt;&lt;P&gt;You could write a macro that converts all date variables to datetime variables with 00:00:00.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 16:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133008#M260764</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-12T16:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133009#M260765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I dont think SQL Server added a date only data type until 2008 and then developers would have to use that for date only fields. Previous datetime I believe was the only storage option (of course the view could be formated to show what every the developer wanted). Since you are having this issue I imagine that your solution, like &lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/" modifiedtitle="true" title="Reeza"&gt;&lt;/A&gt; suggested, is to add the time to the dates you have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have done this in the past as part of the insert sql, but you could do it in a datastep prior to the insert as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 17:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133009#M260765</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-03-12T17:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133010#M260766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand that the data type was only added in 2008, however this seems like a fundamental short-sight of being able to transfer data between two sources. EXAMPLE: What if a sql table has a field that is specified as a "date" format. You cannot then take ANY sas data and get data into this field and have it mapped correctly as a date. If you format it as a standard Date, or character, or Datetime, sas throws the errror (Type of column 2 not recognized).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is some example code that creates such a table and tries to insert data into it.&lt;/P&gt;&lt;P&gt;SQL SERVER CREATE TABLE STATEMENT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create table dates_test(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [KEY]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NUMERIC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; null,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Datefield]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [date]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; null)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on [primary]&lt;/P&gt;&lt;P&gt;go&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sas code to insert into this table&lt;/P&gt;&lt;P&gt;data person;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile datalines delimiter=','; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; informat key best32.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; informat datevalue mmddyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format key best32.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format datevalue mmddyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input key&amp;nbsp; datevalue ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&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;1,01/01/1999&lt;/P&gt;&lt;P&gt;2,02/27/2009&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname CstOrder odbc dsn='odbc_my_odbcname' schema=dbo bulkload=yes DBMAX_TEXT=32000 ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;insert into cstorder.DATES_TEST&lt;/P&gt;&lt;P&gt;select * from person;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there no way to get the date field from SAS into a corresponding date field in an already created sql table? (basically this would imply we cannot use the date field datatype for any tables and have it communicate with sas, which again seems like a massive defect).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Brandon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 18:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133010#M260766</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-03-12T18:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133011#M260767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My appoligies I think I misunderstood your issue. Is it that you have dates in SAS and are trying to use the actual date datatype in SQL server? if that ist the case I have not dealt with that as most of our SQL Server developers just use the historical datetime field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may be better addressed with SAS Tech Support, I would assume that the SAS date field should correctly convert to the SQL server date field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 18:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133011#M260767</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-03-12T18:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133012#M260768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hello esjackso1. That is correct, you have perfectly stated my problem. I am able to get datetimes into sql server, but I cannot get an actual DATE into a field of the datatype DATE, which is a problem because quite a few of our tables are using the "DATE" format (in sql).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will open a ticket with sas tech support, however I am curious if anyone at all has run into this problem before?&lt;/P&gt;&lt;P&gt;Thanks all!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 19:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133012#M260768</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-03-12T19:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133013#M260769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all. I am sorry for the inconvience, I have just discovered how to solve this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It turns out, if you specify the SAS data as a charater value, in the format MMDDYY10., then insert it into the sql table (with the DATE Type) sql server actually convers the character value into a "DATE" field.. (very strange I think).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks all for your time!&lt;/P&gt;&lt;P&gt;Brandon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 19:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133013#M260769</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-03-12T19:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133014#M260770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good to know ... Thanks for posting your solution!&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 19:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133014#M260770</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-03-12T19:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133015#M260771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Doesn't sound like a best practice to me...&lt;/P&gt;&lt;P&gt;Have you tried DBSASTYPE?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 19:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133015#M260771</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-03-12T19:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133016#M260772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is that for when specifying the date as a literal value? or when inserting from a SAS dataset?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 00:06:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133016#M260772</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-13T00:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133017#M260773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can't see any use when specifying constants, since you have the possibility to use the appropriate format when specifying the constant. So it's for column values, and it works both ways (read/write). For inserting, see example 3:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/65247/HTML/default/viewer.htm#n0v4ma1zb9lu99n1728j279rjcqi.htm" title="http://support.sas.com/documentation/cdl/en/acreldb/65247/HTML/default/viewer.htm#n0v4ma1zb9lu99n1728j279rjcqi.htm"&gt;SAS/ACCESS(R) 9.3 for Relational Databases: Reference, Second Edition&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 08:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/133017#M260773</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-03-13T08:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Date into Sql Server -Not Datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/427256#M260774</link>
      <description>&lt;P&gt;Wonder if there's any chance of reviving this as I have a question - I tried using DBSASTYPE in the following context:&lt;/P&gt;&lt;P&gt;data SQLlib.TasksNotRun (DBSASTYPE=(LastRunSuccess='DATE'));&lt;BR /&gt;set TaskList;&lt;BR /&gt;where LastRunSuccess lt LastExpectedRun;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This uses an ODBC connection for the 'SQLlib' libname and I'm using SQL Server 2014 for my databases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The input data column, from the table 'TaskList', is in&amp;nbsp;YYMMDD10. format.&amp;nbsp;However the table it creates in SQL has a datetime format for this column.&lt;/P&gt;&lt;P&gt;Not a disaster for what I'm using it for, but I wanted my output to look nicer...&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 16:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-Date-into-Sql-Server-Not-Datetime/m-p/427256#M260774</guid>
      <dc:creator>RosieT</dc:creator>
      <dc:date>2018-01-12T16:37:48Z</dc:date>
    </item>
  </channel>
</rss>

