Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <n.j.cox@durham.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Delta of two time variables (%tc) in minutes |

Date |
Thu, 21 Oct 2010 12:10:26 +0100 |

We can't tell you what you are doing wrong if you don't show us any of your solutions. On a fundamental point: a variable's (or constant's) format is not a matter of how numbers are stored; it is a matter of how they are displayed. You may know that really, but it's still a misuse of terms to talk that way. This area is one with lots of detail which probably no-one remembers unless they use these functions all the time. I don't either, and each time I have a new question it can be a few minutes with the help before I find what I want. But I have some very simple tips on how to find out. 1. A golden thread linking date-times is that Stata counts (not measures) time, so works with integers, and the units are ms (milliseconds). 2. To check what is being done, fire up -display- and contrive examples to which you know the answer. 3. Use -display- with formats that make sense. The default is not helpful . di tc(21oct2010 12:00) 1.603e+12 So I use plenty of space and use my knowledge that time is an integer . di %21.0f tc(21oct2010 12:00) 1603281600000 In this example I know that the answer must be 5 minutes . di %21.0f tc(21oct2010 12:00) - tc(21oct2010 11:55) 300000 And I can reproduce that by dividing by 60,000. (Evidently there are 60,000 ms in a minute.) . di %21.0f (tc(21oct2010 12:00) - tc(21oct2010 11:55))/60000 5 There are probably quicker ways, which will trump this solution. But the short answer to your question may be as simple as divide by 60000. Nick n.j.cox@durham.ac.uk Kaspar Dardas a quick question on the delta units of two time variables stored in %tc format. How do I get the delta of publishtime - local_time in minutes elapsed (not HH:MM etc... but simply in minutes as numbers)? At first sight this seems pretty simple (I am sure it is for the most of you) but I cant get it right and the time and date help section in the manual drives me virtually crazy. publishtime local_time 19jun2007 12:20:00 19jun2007 12:11:00 * * 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/

**Follow-Ups**:**Re: st: RE: Delta of two time variables (%tc) in minutes***From:*Kaspar Dardas <kaspar.dardas@students.ebs.edu>

**References**:**st: Delta of two time variables (%tc) in minutes***From:*Kaspar Dardas <kaspar.dardas@students.ebs.edu>

- Prev by Date:
**RE: st: Data management** - Next by Date:
**st: Testing for mediation in a multi-level model** - Previous by thread:
**st: Delta of two time variables (%tc) in minutes** - Next by thread:
**Re: st: RE: Delta of two time variables (%tc) in minutes** - Index(es):