Statalist


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

st: RE: ISO 8601 date-time format in Stata 10


From   "Steichen, Thomas J." <SteichT@rjrt.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: ISO 8601 date-time format in Stata 10
Date   Wed, 22 Aug 2007 14:02:21 -0400

Joe,

I think format %tCCCYY-NN-DD!THH:MM:SS gets what you want.

-mytime- below is a double precision variable formated as above.

     +-------------------------------------------+
     |             timestr                mytime |
     |-------------------------------------------|
  1. | 22 08 2007 23:54:00   2007-08-22T23:54:00 |
  2. | 22 08 2007 11:54:01   2007-08-22T11:54:01 |
  3. |  22 08 2007 6:56:10   2007-08-22T06:56:10 |
     +-------------------------------------------+

I generated this by typing in the -timestr- values then
converted them to internal format via:

.. gen double mytime = Clock(timestr, "DMY hms")

Note that you must be careful with -Clock()- vs. clock() 
and other such things to be sure that the leap seconds work out right.

Tom

-----------------------------------
Thomas J. Steichen
steicht@rjrt.com
-----------------------------------
 
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Joseph Coveney
Sent: Thursday, August 23, 2007 3:15 AM
To: Statalist
Subject: st: ISO 8601 date-time format in Stata 10

Could someone show what the format statement is in order to get the
following date-time format for a double-precision variable containing a 
timestamp?

2007-08-22T23:54:00

I've read the help file for dates and times, but am unable to use the new 
syntax correctly.

Joseph Coveney


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

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information. If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system. Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.   

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



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index