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]

st: Extract date and time from a date/time variable


From   Pinaki Mitra <mitrap@comcast.net>
To   statalist@hsphsun2.harvard.edu
Subject   st: Extract date and time from a date/time variable
Date   Wed, 11 May 2011 13:46:16 +0000 (UTC)

Hello,

    I have a date/time variable "ActivityDate" which is double and in %tc format. For example, a value of "ActivityDate" is "01mar2011 11:56:00". I need to extract date and time into two variables. I did gen ActivityDay=dofc( ActivityDate) and format ActivityDay %dN/D/Y which provided me the date as 03/01/11. What can I do to extract "11:56:00" into a new variable "ActivityTime"?

Thank you,
Pinaki Mitra  
*
*   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