[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Re: what time is it?
Quoting baum <email@example.com>:
> --On Friday, September 27, 2002 2:33 -0400 Jesper wrote:
> > Karim,
> > unless I am mssing something, you just need to convert it into days since
> > Jan 1 1960, and then use Stata's date functions.
> > gen daystamp=timestamp/(24*60*60)
> > - -- daystamp is now days since 1/1/1970.
> > now compute the n of days between 1/1/1960 and 1/1/1970.
> > . di date("1/1/1970","mdy")
> > 3653
> > so
> > replace daystamp=daystamp+3653
> > and
> > format daystamp %d
> I believe that what Karim and Liz Allred are asking for is the ability to
> have the granularity of time in HH:MM:SS, as is present in the *nix
> timestamp. Your solution has a maximal resolution of one day. What if we
> need to know whether the patient took the drug at 0802 or 1617 that day?
> Given Stata's medical orientation and the use of time-of-day in
> experimental data, it surprises me that this omission has not been
We should distinguish between the number that is generated by the above
procedure (which includes fractions of days) and the date format, which only
displays the day. For example, Jan 4, 1960 at 2:06:00 am is 266760 seconds
since midnight on Jan 1, 1960. The transformation above generate a daystamp
value of 3.0875, where .0875=126 minutes out of a day.
At 2:06:04 am (four seconds later), the value of the daystamp variable would be
3.087546, since 4/(24*60*60)=.0000463.
I agree that it might be nice in some situations to have a format that specified
the exact time as well as the day.
So, unless you truncate it, the granularity of the timing is in the daystamp
> Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA
> firstname.lastname@example.org http://fmwww.bc.edu/ec-v/baum.fac.html
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
* For searches and help try: