Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: RE: working with timestamps with milliseconds


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: working with timestamps with milliseconds
Date   Sun, 21 Feb 2010 10:00:33 +0100

<>

You requested -format- %tc, and the -help dates_and_times- gives you the
following advice:



                 +-----------------------------------------------+
                 | DO NOT FORGET                                 |
                 |                                               |
                 | %tc and %tC values MUST BE stored as doubles. |
                 | Doing so is your responsibility, not Stata's. |
                 +-----------------------------------------------+



HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David Souther
Sent: Sonntag, 21. Februar 2010 02:30
To: [email protected]
Subject: st: working with timestamps with milliseconds

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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index