[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)


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?


----- 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 ------------
input str8 time1 str8 time2
"10:30:25" "10:31:10"
gen t1 = clock(time1,"hms")
gen t2 = clock(time2,"hms")
format t1 %tc
format t2 %tc
gen diff_in_seconds = (t2-t1)/1000
*---------- end example -------------

Hope this helps,

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


*   For searches and help try:

Χρησιμοποιείτε Yahoo!; 
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail 
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών 

*   For searches and help try:

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