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: Question: date format
From
Joe Canner <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: Question: date format
Date
Thu, 12 Sep 2013 13:19:26 +0000
Thomas,
I don't see anything in the documentation about displaying a Stata datetime variable as just a time. Generally speaking, times without dates are kind of useless, which is probably why they didn't provide for this.
I would suggest you combine the date variable and the time variable into one datetime variable. Say your original date variable is -date1- and your time variable is -time1-:
. gen datetime1=cofd(date1)+time1
-cofd()- converts your date to a datetime with midnight as the time. Your time variable is the number of milliseconds past midnight. So, the sum should be a legitimate datetime variable.
Later, if you need information on just the time you can extract it using the hh(), mm(), and ss() functions.
Regards,
Joe Canner
Johns Hopkins University School of Medicine
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Bourveau
Sent: Thursday, September 12, 2013 8:40 AM
To: [email protected]
Subject: st: Question: date format
Dear Statalist members,
I obtained data on the timing of some announcements made by firms. For each event, I have two different variables: one variable for the date, and another one for the hours, minutes and seconds of the timing.
However, when I obtained the second variable, it looks like this:
01jan1960 13:57:54
01jan1960 23:17:48
01jan1960 08:32:52
Specifically, for each line, "01jan1960" is written before each hours, which was not supposed to be.
The variable is in a long format (%tcHH:MM:SS) and I don't know how to drop the "01jan1960" for each line.
If anyone has a suggestion, that would be nice.
Thanks a in advance
Best,
Thomas
--
Thomas Bourveau
[email protected]
0637573925
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/