Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Difference between times


From   Nikolaos Kanellopoulos <[email protected]>
To   [email protected]
Subject   Re: st: Difference between times
Date   Fri, 11 Sep 2009 04:49:34 -0700 (PDT)

Maarten,


thanks very much for this. 

However, can the final result appear in the format of HH:MM:SS? In your example something like 00:00:45?

Nikos


----- Original Message ----
From: Maarten buis <[email protected]>
To: [email protected]
Sent: Friday, September 11, 2009 10:15:12 AM
Subject: Re: st: Difference between times

--- On Fri, 11/9/09, Nikolaos Kanellopoulos wrote:
> I have two variables showing the starting and ending time
> of an event. These variables are of the form 10:30:25
> (hours:minutes:seconds).
> 
> I want to estimate the difference between the two and
> display their difference in the same format.

*--------- begin example ------------
clear
input str8 time1 str8 time2
"10:30:25" "10:31:10"
end
gen t1 = clock(time1,"hms")
gen t2 = clock(time2,"hms")
format t1 %tc
format t2 %tc
gen diff_in_seconds = (t2-t1)/1000
list
*---------- end example -------------

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   For searches and help try:
*  http://www.stata.com/help.cgi?search
*  http://www.stata.com/support/statalist/faq
*  http://www.ats.ucla.edu/stat/stata/



      
___________________________________________________________ 
Χρησιμοποιείτε Yahoo!; 
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail 
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών 
μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr 



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index