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

Re: st: working with timestamps with milliseconds


From   Michael Mitchell <Michael.Norman.Mitchell@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: working with timestamps with milliseconds
Date   Sun, 21 Feb 2010 19:12:53 -0800

Dear David

  Now you are bumping up against the default display format... from
the help file (help dates_and_times), the implied format is...

            Format | Implied (fully specified) format
            -------+---------------------------------
            %tc    | %tcDDmonCCYY_HH:MM:SS

 So we can manually specify the format to get the entire precision,
for example...

. clear

. inp str30 time
                               time
  1. "1-22-2007 3:44:22"
  2. "1/23/2008 02:23:11.111"
  3. end

. gen double time2 = clock(time, "MDY hms")
. format time2 %tcDDmonCCYY_HH:MM:SS.sss
. li

     +-------------------------------------------------+
     |                   time                    time2 |
     |-------------------------------------------------|
  1. |      1-22-2007 3:44:22   22jan2007 03:44:22.000 |
  2. | 1/23/2008 02:23:11.111   23jan2008 02:23:11.111 |
     +-------------------------------------------------+

Best regards,
--
Michael N. Mitchell
See the Stata tidbit of the week at...
http://www.MichaelNormanMitchell.com
Visit me on Facebook at...
http://www.facebook.com/MichaelNormanMitchell
*
*   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