<?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: Compatibility between date types in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771401#M244791</link>
    <description>&lt;P&gt;We can't go further without seeing the LOG for the PROC SQL (all of the log for this PROC SQL, not part of the log).&lt;/P&gt;</description>
    <pubDate>Thu, 30 Sep 2021 15:33:27 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-09-30T15:33:27Z</dc:date>
    <item>
      <title>Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771389#M244782</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I performed a union between two selects.&lt;BR /&gt;In the first select the date field (ajt.DTC_MOV)) is numeric in datetime 22.3 format. The results are in the format 03JAN2019:00:00:00.000.&lt;/P&gt;&lt;P&gt;In the second select, the date field (ajt.DTC_MOV) is numeric without a defined format (the dates are extracted from an excel spreadsheet). The results are in the format 1935705600.&lt;/P&gt;&lt;P&gt;When performing the UNION data field it shows the results in the format 1935705600.&lt;/P&gt;&lt;P&gt;My question is how to display them in the format 03JAN2019:00:00:00.000. I've tried the solutions below without success in the select clause:&lt;BR /&gt;- DHMS(ajt.DTC_MOV,0,0,0)&lt;BR /&gt;- datepart (DHMS(ajt.DTC_MOV,0,0,0)) format = datetime22.3&lt;BR /&gt;- datepart (ajt.DTC_MOV) format = datetime22.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 14:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771389#M244782</guid>
      <dc:creator>AlexSP</dc:creator>
      <dc:date>2021-09-30T14:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771394#M244786</link>
      <description>&lt;P&gt;The formats in the two tables are irrelevant here. The key issue is whether the variables are date/time variables or date variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you say one is formatted as datetime22.3 and the other shows as&amp;nbsp;&lt;SPAN&gt;1935705600, these are most likely both date/time values, and so there should be no problem doing a UNION as these are both date/time values. (Note: sometimes date and datetime values in Excel have to be adjusted in SAS, search the SAS Communities for the proper adjustment)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;There is also no reason to use DATEPART if you want the results to look like&amp;nbsp;03JAN2019:00:00:00.000, because DATEPART gives you dates, not date/times which is what you want. So take DATEPART out of your code, and you should find it works.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 14:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771394#M244786</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-30T14:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771397#M244788</link>
      <description>&lt;P&gt;Thank you for your prompt response, but the result is still in the 1924214400 format.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 15:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771397#M244788</guid>
      <dc:creator>AlexSP</dc:creator>
      <dc:date>2021-09-30T15:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771398#M244789</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/387964"&gt;@AlexSP&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your prompt response, but the result is still in the 1924214400 format.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show your actual code from the LOG with the notes and messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your numeric value of&amp;nbsp;&amp;nbsp; 192421440 shows 22DEC2020:00:00:00 or similar in Excel then your issue is in assigning the format. Or you didn't replace the first data set and are seeing the previous values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 15:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771398#M244789</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-30T15:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771401#M244791</link>
      <description>&lt;P&gt;We can't go further without seeing the LOG for the PROC SQL (all of the log for this PROC SQL, not part of the log).&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 15:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771401#M244791</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-30T15:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771423#M244805</link>
      <description>&lt;P&gt;Unfortunately due to organizational rules I cannot share such material. But I keep trying to resolve this issue of the date.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 16:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771423#M244805</guid>
      <dc:creator>AlexSP</dc:creator>
      <dc:date>2021-09-30T16:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771429#M244808</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/387964"&gt;@AlexSP&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Unfortunately due to organizational rules I cannot share such material. But I keep trying to resolve this issue of the date.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which specific material can you not share? Code? Variable names? or actual values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps two small dummy data sets with only a couple of values of similar ranges and code to work them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, can't help. It's like medicine in the middle ages when the doctor sat outside the room a sick noblewoman was in asking her to describe the symptoms and "diagnosing" an illness.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 17:04:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771429#M244808</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-30T17:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771430#M244809</link>
      <description>&lt;P&gt;Can't share the LOG?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 17:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771430#M244809</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-30T17:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771433#M244810</link>
      <description>&lt;P&gt;So it looks like both values are datetime (number of seconds), but they do represent different values that are about 28 months apart.&lt;/P&gt;
&lt;PRE&gt;529   data check;
530     dt1='03JAN2019:00:00:00.000'dt;
531     dt2=1935705600 ;
532     put (dt1 dt2) (=datetime19.);
533     put (dt1 dt2) (=comma20.);
534   run;

dt1=03JAN2019:00:00:00 dt2=04MAY2021:00:00:00
dt1=1,862,092,800 dt2=1,935,705,600
&lt;/PRE&gt;
&lt;P&gt;Why are you trying to change the type of the values by using DHMS() or DATEPART() functions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If DTC already has number of seconds values then you would want to put it into the S part of the DHMS() function call, not the D part.&lt;/P&gt;
&lt;P&gt;If you convert from number of seconds to number of days using the DATEPART() function then you will want to attach a date type format (DATE, YYMMDD, etc) to the variable and not a datetime type format.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 17:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771433#M244810</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-30T17:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771475#M244829</link>
      <description>PaigeMiller, I have not permission to share the LOG.&amp;nbsp;&lt;BR /&gt;Ballarddw,&lt;BR /&gt;In Excel I have the dates like&lt;BR /&gt;03/05/2021&lt;BR /&gt;04/05/2021&lt;BR /&gt;* First select&lt;BR /&gt;I have date in the format 03MAY2021:00:00:00.000 (numeric, datetime 22.3 format)&lt;BR /&gt;* Second select (over the Excel)&lt;BR /&gt;I have date in the format 05/03/2021 (numeric, mmddyy10. format).&lt;BR /&gt;&lt;BR /&gt;*but After UNION&lt;BR /&gt;I got the date in the format like 1935705600&lt;BR /&gt;&lt;BR /&gt;Tom, I have used your solution but it did not work.&lt;BR /&gt;&lt;BR /&gt;As I am new in SAS programming, I am reading all I can to understand how dates function works to be able to alter the date.&amp;nbsp;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Sep 2021 19:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771475#M244829</guid>
      <dc:creator>AlexSP</dc:creator>
      <dc:date>2021-09-30T19:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771477#M244831</link>
      <description>&lt;P&gt;If you can't share the log, then I recommend you find someone at your company who can help you, since I assume he can come over to your office and see the log that way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, it does NOT matter what you see in Excel. It is a mistake to look in Excel. You need to look in the SAS data sets and then you should be able to determine if your values are dates or date/times.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If you are getting&amp;nbsp;&lt;SPAN&gt;1935705600 then you have a datetime value, and you should format it as datetime22.3 (or similar), partial SQL code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ajt.DTC_MOV format=datetime22.3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 19:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771477#M244831</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-30T19:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771481#M244832</link>
      <description>Analysts here don't know either. As there is an appreciation of IT professionals (which is good) old analysts who had more knowledge have already left.&lt;BR /&gt;&lt;BR /&gt;I put this code ajt.DTC_MOV format=datetime22.3 in both selects. The result is in the correct format, but with the wrong result: 01JAN1960:06:19:28,000 instead 03MAY2021.&lt;BR /&gt;&lt;BR /&gt;* Select 1: dac.dtc_credito format = datetime22.3 as d1&lt;BR /&gt;union&lt;BR /&gt;* Select 2: ajt.DTC_MOV format=datetime22.3 as d2&lt;BR /&gt;Result: 01JAN1960:06:19:28,000</description>
      <pubDate>Thu, 30 Sep 2021 20:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771481#M244832</guid>
      <dc:creator>AlexSP</dc:creator>
      <dc:date>2021-09-30T20:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771483#M244833</link>
      <description>&lt;P&gt;Correcting&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;* Select 1: dac.dtc_credito format = datetime22.3 as d1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;union&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* Select 2: ajt.DTC_MOV format=datetime22.3 as d1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Result: 01JAN1960:06:19:28,000&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 20:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771483#M244833</guid>
      <dc:creator>AlexSP</dc:creator>
      <dc:date>2021-09-30T20:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771493#M244837</link>
      <description>Eureka!&lt;BR /&gt;&lt;BR /&gt;Solution for this problem:&lt;BR /&gt;&lt;BR /&gt;* Select 1: datepart (dac.dtc_credito) format = mmddyy10. as D1&lt;BR /&gt;UNION&lt;BR /&gt;* Select 2: ajt.DTC_MOV as D1&lt;BR /&gt;Result: 05/03/2021, as desired.&lt;BR /&gt;Thanks PaigeMiller, Tom, BallarDW for the help.</description>
      <pubDate>Thu, 30 Sep 2021 20:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771493#M244837</guid>
      <dc:creator>AlexSP</dc:creator>
      <dc:date>2021-09-30T20:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Compatibility between date types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771510#M244842</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/387964"&gt;@AlexSP&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Eureka!&lt;BR /&gt;&lt;BR /&gt;Solution for this problem:&lt;BR /&gt;&lt;BR /&gt;* Select 1: datepart (dac.dtc_credito) format = mmddyy10. as D1&lt;BR /&gt;UNION&lt;BR /&gt;* Select 2: ajt.DTC_MOV as D1&lt;BR /&gt;Result: 05/03/2021, as desired.&lt;BR /&gt;Thanks PaigeMiller, Tom, BallarDW for the help.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But this doesn't give you a date/time format as you have been asking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nor does it seem to correspond to the question originally asked.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 21:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compatibility-between-date-types/m-p/771510#M244842</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-30T21:32:38Z</dc:date>
    </item>
  </channel>
</rss>

