<?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 Date-time excel variable into SAS date issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688252#M209037</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm importing a excel file into SAS. While importing, the date time which has 9/1/2020 7:28:11 AM (Date/time format) in Excel gets converted into a Text in SAS environment into 22159.311234.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found the solution to convert this original date and time&amp;nbsp; per below SAS code. However, I am not getting date incorrect but time is showing correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The date should be 01SEP2020 however it showing as 31AUG1960.&lt;/P&gt;&lt;P&gt;The time is showing correctly as&amp;nbsp;&amp;nbsp;7:28:11 AM using the SAS code suggested.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set review.QueryDetail;

 format date date9.;
 format time timeampm.;
 format dt datetime21.;
 qdate = input(querydate,??best.);
 date=int(qdate)-21916;
 time=(qdate-int(qdate))*60*60*24;
 dt=date*24*60*60+time;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The other code suggested here also used but I am getting same issue, it showing as 31AUG1960.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set review.QueryDetail;

 format sasdate date9.;&lt;BR /&gt;
 qdate = input(querydate,??best.);
 Adjusted_Datetime = (qdate + '30dec1899'd) * 86400;
 sasdate = datepart(Adjusted_Datetime);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 634px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50067i84E3198B7EE6A3CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 405px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50068i66A0AF77726549DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please let me know how to get back the original date and time in date/time format in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know there are many suggestion to convert the excel file into csv as excel has lots of issue but unfortunately I cant convert these into csv.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Anil&lt;/P&gt;</description>
    <pubDate>Thu, 01 Oct 2020 15:17:05 GMT</pubDate>
    <dc:creator>AnilGaurav</dc:creator>
    <dc:date>2020-10-01T15:17:05Z</dc:date>
    <item>
      <title>Date-time excel variable into SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688252#M209037</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm importing a excel file into SAS. While importing, the date time which has 9/1/2020 7:28:11 AM (Date/time format) in Excel gets converted into a Text in SAS environment into 22159.311234.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found the solution to convert this original date and time&amp;nbsp; per below SAS code. However, I am not getting date incorrect but time is showing correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The date should be 01SEP2020 however it showing as 31AUG1960.&lt;/P&gt;&lt;P&gt;The time is showing correctly as&amp;nbsp;&amp;nbsp;7:28:11 AM using the SAS code suggested.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set review.QueryDetail;

 format date date9.;
 format time timeampm.;
 format dt datetime21.;
 qdate = input(querydate,??best.);
 date=int(qdate)-21916;
 time=(qdate-int(qdate))*60*60*24;
 dt=date*24*60*60+time;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The other code suggested here also used but I am getting same issue, it showing as 31AUG1960.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set review.QueryDetail;

 format sasdate date9.;&lt;BR /&gt;
 qdate = input(querydate,??best.);
 Adjusted_Datetime = (qdate + '30dec1899'd) * 86400;
 sasdate = datepart(Adjusted_Datetime);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 634px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50067i84E3198B7EE6A3CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 405px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50068i66A0AF77726549DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please let me know how to get back the original date and time in date/time format in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know there are many suggestion to convert the excel file into csv as excel has lots of issue but unfortunately I cant convert these into csv.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Anil&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 15:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688252#M209037</guid>
      <dc:creator>AnilGaurav</dc:creator>
      <dc:date>2020-10-01T15:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Date-time excel variable into SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688255#M209039</link>
      <description>&lt;P&gt;If you have a character value then perhaps this will show you a way with a different INFORMAT.&lt;/P&gt;
&lt;PRE&gt;data example;
 x="9/1/2020 7:28:11 AM";
 y= input(x,anydtdtm32.);
 format y datetime18.;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Oct 2020 15:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688255#M209039</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-01T15:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Date-time excel variable into SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688270#M209045</link>
      <description>&lt;P&gt;Looks like the INT value of your qdate is already correct, so you only need to transform the time. Do not subtract the 21916 when you calculate the date.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 15:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688270#M209045</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-01T15:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date-time excel variable into SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688306#M209060</link>
      <description>Thanks for your quick response, it does works.</description>
      <pubDate>Thu, 01 Oct 2020 17:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-time-excel-variable-into-SAS-date-issue/m-p/688306#M209060</guid>
      <dc:creator>AnilGaurav</dc:creator>
      <dc:date>2020-10-01T17:39:39Z</dc:date>
    </item>
  </channel>
</rss>

