Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: working with timestamps with milliseconds


From   David Souther <davidsoutheremail@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: working with timestamps with milliseconds
Date   Sat, 20 Feb 2010 19:29:49 -0600

I couldn't find a solution to this in the Statalist archives, and this
may be in the dates/times help file but I've read through it a couple
of time and cannot find (or probably don't understand this file enough
to find) the solution for how to work with milliseconds.
Every time I format a timestamp that includes the MDY along with
hours, minutes, seconds and milliseconds, the seconds/milliseconds are
off by a minute or so.  I did see the section on leap seconds, but I"m
not sure how that plays into my example and if there is a way to just
show and work with the exact timestamp that I input into Stata.
Here's what I do

clear
inp str30 time
"1-22-2007 3:44:22"
"1/23/2008 02:23:11.11"
end

gen time2 = clock(time, "MDY hms")
format time2 %tC

gen d2 = clock("2/22/2002 14:22:33.232", "MDY hms")
format d2 %tc


This gives me --

     +-----------------------------------------------------------------+
     |                  time                time2                   d2 |
     |-----------------------------------------------------------------|
  1. |     1-22-2007 3:44:22   22jan2007 03:43:35   22feb2002 14:23:02 |
  2. | 1/23/2008 02:23:11.11   23jan2008 02:23:17   22feb2002 14:23:02 |
     +-----------------------------------------------------------------+
Notice that the time changed in from things like 3:44:22  to 3:43:35.

I tried using %tC as well.  I use Stata 11 on Windows.  Any hints?

Thanks,

David
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index