<?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: Trouble getting a specific datetime format as a string for passing to a SPROC in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583957#M7896</link>
    <description>Format EndDate datetime. to see it .&lt;BR /&gt;&lt;BR /&gt;I'd suggest using datepart and timepart to get each in a string format you want...then concatenate them.&lt;BR /&gt;&lt;BR /&gt;This should help you:  &lt;A href="https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm" target="_blank"&gt;https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm&lt;/A&gt;</description>
    <pubDate>Mon, 26 Aug 2019 15:38:26 GMT</pubDate>
    <dc:creator>tomrvincent</dc:creator>
    <dc:date>2019-08-26T15:38:26Z</dc:date>
    <item>
      <title>Trouble getting a specific datetime format as a string for passing to a SPROC</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583930#M7894</link>
      <description>&lt;P&gt;I have a macro that calls a SPROC to a SQL Server. The program wrapped around it calls this macro for several different categorical values using the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;
	set work.categoryTable;
	endDate = datetime();
	call execute('%queryData(Categ='|| categ ||', BeginDate='|| beginDate ||', EndDate='|| endDate ||');');
run;&lt;/PRE&gt;&lt;P&gt;Code within the queryData macro appends all of the queried data from each iteration into a singular table. I have an existing table that I queried with hard coded date strings. This table has datetime values within it, and I pull the most recent from said table and match it to work.categoryTable as appropriate, which is where the beginDate variable comes from. The goal here is to access the new data that isn't yet present in the main table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a program that I intend to set up using the jobs system to run daily, which means that I can't hard code the date strings moving forward. The problem that I'm running into is how to take the beginDate and endDate and pass them to the macro as a string in the format that will work with the SPROC. Additionally, I didn't create the SPROC so I don't have much flexibility in the format of the date string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The format that I need to pass as a string looks akin to this: '8/26/2019 10:30:00'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the time that the call statement is processed, the table set from categoryTable and modified with the endDate variable looks like this:&lt;/P&gt;&lt;PRE&gt;CATEG   |   BeginDate              |   EndDate
categ1      14AUG2019:23:56:15.000     &lt;SPAN class="sapMText sapMTextBreakWord sapMTextMaxWidth sasMText"&gt;1882433719.2&lt;/SPAN&gt;
categ2      14AUG2019:22:32:19.000     &lt;SPAN class="sapMText sapMTextBreakWord sapMTextMaxWidth sasMText"&gt;1882433719.2&lt;/SPAN&gt;
categ3      12AUG2019:14:44:52.000     &lt;SPAN class="sapMText sapMTextBreakWord sapMTextMaxWidth sasMText"&gt;1882433719.2&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Where BeginDate is classified as a 'Time' variable when hovering over the column name and EndDate is a 'numeric'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for the assistance.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 14:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583930#M7894</guid>
      <dc:creator>Hungry2Learn</dc:creator>
      <dc:date>2019-08-26T14:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble getting a specific datetime format as a string for passing to a SPROC</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583950#M7895</link>
      <description>&lt;P&gt;You would just need to change the code slightly, instead of using begin date use:&lt;BR /&gt;&lt;BR /&gt;put(begin_date, FORMAT.)&lt;BR /&gt;&lt;BR /&gt;You'll unfortunately likely need a picture format for that specific date format but I also know I've answered this exact question at least twice in the past month on here so it's on here if you do some search with picture formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Datetime-conversion/m-p/580601/highlight/true#M164942" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Datetime-conversion/m-p/580601/highlight/true#M164942&lt;/A&gt;&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;proc format;
picture dtStamp (round) 
low - high = '%m/%0d/%Y %0H:%0M:%0S' (datatype=datetime);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 15:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583950#M7895</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-26T15:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble getting a specific datetime format as a string for passing to a SPROC</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583957#M7896</link>
      <description>Format EndDate datetime. to see it .&lt;BR /&gt;&lt;BR /&gt;I'd suggest using datepart and timepart to get each in a string format you want...then concatenate them.&lt;BR /&gt;&lt;BR /&gt;This should help you:  &lt;A href="https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm" target="_blank"&gt;https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm&lt;/A&gt;</description>
      <pubDate>Mon, 26 Aug 2019 15:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583957#M7896</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-08-26T15:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble getting a specific datetime format as a string for passing to a SPROC</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583961#M7897</link>
      <description>&lt;P&gt;Thanks, this worked excellently for both the begin/end dates.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 15:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Trouble-getting-a-specific-datetime-format-as-a-string-for/m-p/583961#M7897</guid>
      <dc:creator>Hungry2Learn</dc:creator>
      <dc:date>2019-08-26T15:42:09Z</dc:date>
    </item>
  </channel>
</rss>

