<?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: ADO connection from Excel - SAS date format problem - rs.Properties(&amp;quot;SAS Formats&amp;quot;) = &amp;quot;_ALL_&amp;quot; NOT WORKING in Microsoft Integration with SAS</title>
    <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124429#M1312</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case you don't know, to convert SAS Date to Office Date you should add 21916 to the SAS date field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if DataSourceType(Table, Field)=vbDate then rs.Field("date")=rs.Field("date")+21916&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Feb 2014 20:11:47 GMT</pubDate>
    <dc:creator>KenjiAneel</dc:creator>
    <dc:date>2014-02-04T20:11:47Z</dc:date>
    <item>
      <title>ADO connection from Excel - SAS date format problem - rs.Properties("SAS Formats") = "_ALL_" NOT WORKING</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124427#M1310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I try to connect Excel to SAS using ADO but encountered a problem&amp;nbsp; - SAS returns recordset that contain DATE columns only in SAS format eg. 19236 (instead 2012-08-31)&lt;/P&gt;&lt;P&gt;I went through whole &lt;A href="http://www.technion.ac.il/docs/sas9/book_files/58657.pdf" title="http://www.technion.ac.il/docs/sas9/book_files/58657.pdf"&gt;http://www.technion.ac.il/docs/sas9/book_files/58657.pdf&lt;/A&gt; and tried to set :&lt;/P&gt;&lt;P&gt;rs.Properties("SAS Formats") = "_ALL_"&lt;/P&gt;&lt;P&gt;rs.Properties("SAS Informats") = "_ALL_"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which should enforce SAS to use data type defined in table (all date formats and informats are YYMMDD10.) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Itried also &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rs.Properties("SAS Formats") = "date=YYMMDD10."&lt;/P&gt;&lt;P&gt;rs.Properties("SAS Informats") = "date=YYMMDD10."&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NO SUCCESS!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;My code is following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub get_ado_table_from_sas()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Error GoTo err:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim db As New ADODB.Connection&lt;/P&gt;&lt;P&gt;Dim rs As New ADODB.Recordset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim errorstring As String&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Path = "C:\dokumenty\!sas_biblioteki\TESTOWE_OBLICZENIA\PR_NARZEDZIE"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set obWS = obWSM.Workspaces.CreateWorkspaceByServer("Local", _&lt;/P&gt;&lt;P&gt;VisibilityProcess, Nothing, "", "", errorstring)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;db.Open "provider=sas.iomprovider.1; SAS Workspace ID=" + obWS.UniqueIdentifier&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rs.ActiveConnection = db&lt;/P&gt;&lt;P&gt;rs.Properties("SAS Formats") = "_ALL_"&lt;/P&gt;&lt;P&gt;rs.Properties("SAS Informats") = "_ALL_"&lt;/P&gt;&lt;P&gt;rs.Open "pr_arch.cal_repl_port_str", db, adOpenDynamic, adLockReadOnly, adCmdTableDirect&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cells(6, 1).CopyFromRecordset rs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rs.Close&lt;/P&gt;&lt;P&gt;db.Close&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exit Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;err:&lt;/P&gt;&lt;P&gt;MsgBox err.Description&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 13:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124427#M1310</guid>
      <dc:creator>tom12122</dc:creator>
      <dc:date>2012-11-13T13:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: ADO connection from Excel - SAS date format problem - rs.Properties("SAS Formats") = "_ALL_" NOT WORKING</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124428#M1311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I presume when you tried "_ALL_" you got your dates but in string format.&lt;/P&gt;&lt;P&gt;To identify the format of the specific Field you can use the OpenSchema method. In my case, I wanted to return vbDate if the field is identified as such:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Private Function DataSourceType(TableName As String, FieldName As String) As Integer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim RSSchema As New ADODB.Recordset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Integer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataSourceType= 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set RSSchema = pSourceDB.ActiveConnection.OpenSchema(adSchemaColumns, Array(Empty, Empty, TableName))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until RSSchema.EOF&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If RSSchema!COLUMN_NAME = FieldName Then&lt;/P&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; If RSSchema!FORMAT_NAME = "DATE" Then DataSourceType= 7 ' adDate&lt;/P&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; Exit Do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RSSchema.MoveNext&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With this, I think you are all set.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Feb 2014 20:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124428#M1311</guid>
      <dc:creator>KenjiAneel</dc:creator>
      <dc:date>2014-02-04T20:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: ADO connection from Excel - SAS date format problem - rs.Properties("SAS Formats") = "_ALL_" NOT WORKING</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124429#M1312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case you don't know, to convert SAS Date to Office Date you should add 21916 to the SAS date field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if DataSourceType(Table, Field)=vbDate then rs.Field("date")=rs.Field("date")+21916&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Feb 2014 20:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124429#M1312</guid>
      <dc:creator>KenjiAneel</dc:creator>
      <dc:date>2014-02-04T20:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: ADO connection from Excel - SAS date format problem - rs.Properties("SAS Formats") = "_ALL_" NOT WORKING</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124430#M1313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kenji,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you expand a little on your last reply?&amp;nbsp; I can't get the Properties("SAS Informats") = "_ALL_" to work either.&amp;nbsp; What is the DataSourceType etc?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 19:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/ADO-connection-from-Excel-SAS-date-format-problem-rs-Properties/m-p/124430#M1313</guid>
      <dc:creator>BU2B</dc:creator>
      <dc:date>2015-03-11T19:05:55Z</dc:date>
    </item>
  </channel>
</rss>

