Statalist


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

Re: st: Difference between times


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Difference between times
Date   Fri, 11 Sep 2009 07:15:12 +0000 (GMT)

--- 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/



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