<?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: difference between two time fields in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975444#M378118</link>
    <description>&lt;P&gt;You have assigned formats to these variables that do not show fractions of a second. If your format did show fractions of a second, then you should see the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 21 Sep 2025 18:27:33 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2025-09-21T18:27:33Z</dc:date>
    <item>
      <title>difference between two time fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975440#M378117</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;In my data set there are two time fields.&lt;/P&gt;
&lt;P&gt;With my eyes I see same time in both fields.&lt;/P&gt;
&lt;P&gt;I calculate difference between them (difference time in seconds) and I expect to get 0 but I get positive number&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table a as
select  Matefet_Offer_Time,application_Time,Matefet_Offer_Time-application_Time as dif
from ttt_A1e
where Agreement_Account_Id=649012587
;
quit;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1758473274484.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/110072iD357195437287B61/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1758473274484.png" alt="Ronein_0-1758473274484.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Sep 2025 16:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975440#M378117</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-09-21T16:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: difference between two time fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975444#M378118</link>
      <description>&lt;P&gt;You have assigned formats to these variables that do not show fractions of a second. If your format did show fractions of a second, then you should see the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Sep 2025 18:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975444#M378118</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-09-21T18:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: difference between two time fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975445#M378119</link>
      <description>&lt;P&gt;If you only want the difference in seconds then round or truncate the values to integers.&lt;/P&gt;
&lt;P&gt;You might want to think about whether you want to round before the subtraction or round afterwards as the order can effect the results.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    data test;
2      t1='22:09:43't + 0.22 ;
3      t2='22:09:43't - 0.22 ;
4      format t1 t2 tod8.;
5      diff = t1-t2 ;
6      put t1= t2= diff=;
7      put t1=time12.3 t2=time12.3 diff= ;
8      diff = round(t1-t2,1);
9      put t1=time12.3 t2=time12.3 diff= ;
10     diff = round(t1,1) - round(t2,1);
11     put t1=time12.3 t2=time12.3 diff= ;
12     diff = int(t1) - int(t2);
13     put t1=time12.3 t2=time12.3 diff= ;
14     diff = int(t1-t2);
15     put t1=time12.3 t2=time12.3 diff= ;
16   run;

t1=22:09:43 t2=22:09:43 diff=0.44
t1=22:09:43.220 t2=22:09:42.780 diff=0.44
t1=22:09:43.220 t2=22:09:42.780 diff=0
t1=22:09:43.220 t2=22:09:42.780 diff=0
t1=22:09:43.220 t2=22:09:42.780 diff=1
t1=22:09:43.220 t2=22:09:42.780 diff=0
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Sep 2025 19:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975445#M378119</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-21T19:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: difference between two time fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975460#M378125</link>
      <description>&lt;P&gt;As Tom showed you , just keep integer part of time and drop decimal part of time by INT() if you want to compare two TIME or DATETIME variable.&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table a as
select  Matefet_Offer_Time,application_Time,
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;int(&lt;/STRONG&gt; &lt;/FONT&gt;Matefet_Offer_Time &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/FONT&gt; - &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;int(&lt;/STRONG&gt; &lt;/FONT&gt;application_Time &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt; as dif
from ttt_A1e
where Agreement_Account_Id=649012587
;
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Sep 2025 07:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975460#M378125</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-22T07:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: difference between two time fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975463#M378126</link>
      <description>&lt;P&gt;Always keep in mind that in SAS, time and datetime values are&amp;nbsp;&lt;U&gt;counts of seconds&lt;/U&gt;. A fractional difference must therefore come from fractions of seconds, which are not displayed by the formats assigned to your variables.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Sep 2025 08:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/difference-between-two-time-fields/m-p/975463#M378126</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-09-22T08:12:30Z</dc:date>
    </item>
  </channel>
</rss>

