Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Time of day


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Time of day
Date   Thu, 28 Aug 2008 12:50:50 +0100

I tried hard to forget the minor agonies of writing -?timeofday- once
StataCorp had done the job properly in Stata 10. 

But times in hours from -ntimeofday- are (as with all Stata date-times)
measured relative to 1 January 1960. Some simple calculations show that
hours above about 400000 are what you should get for recent dates. For
example, today's date gives 

. di 24 * mdy(8,28,2008)
426528

So, my impression is that you got what you asked for, i.e. the result
_is_ in hours. 

I wrote the -?timeofday- stuff because (a) some colleagues needed it (b)
StataCorp did not seem inclined to do it. (b) was promptly reversed, but
a consequence of (a) is that I have not used the official time of day
stuff myself in Stata 10. But I would be surprised if you cannot get
what you want using official commands. 

Nick 
[email protected] 

Alexander.Severinsen

I use Stata 10. I have a string variable, result_date, that records day,
month, year, hours, minutes, seconds. It displays, 11.02.2008
08:21:00.000

I would like to generate a new variable that only indicates hours. I had
a look at the ntimeofday, written by Nicholas J. Cox (findit
ntimeofday), and issed the following command,

ntimeofday result_date, gen(ndatetime) s(dmy h mi s) n(h)

It runs ok, but listing some of these values gives me

list ndatetime in 1/2
  | ndatetime |
     |-----------|
  1. | 421760.35 |
  2. | 421759.92 |

I am not sure whether I am on the right track, and maybe all I am
missing is to translate these numbers into hours? Any help would be
greatly appreciated.


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