Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Date + Time of Day


From   Sylvain Friederich <ecsjf@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Date + Time of Day
Date   Thu, 16 Jun 2005 15:02:11 +0100 (BST)

I don't know if this is useful or more for the sake of
completeness but I tend to go down the (equivalent)
route suggested by Eric at the end of his original
message - just parse out all time and date information
from the original string variable and perhaps do:

. egen double tstp=dhms(edate hr min sec)

which, as far as I understand, is the same as:

. g double tstp = edate + (hr + min/60 + sec/3600)/24

Alternatively, Bill Gould once suggested to create a
variable containing the number of seconds since
01jan1960 00:00:00:

. gen double esecs = date*24*60*60 + hour*60*60 +
min*60 + sec

Best wishes,

Sylvain

--- David Harrison <david.harrison@icnarc.org> wrote:

> As an alternative to Joseph's ODBC suggestion... If
> you have StatTransfer, then you can bring the data
> into Stata with -inputst- and this will bring the
> date/time field in as a numeric daily date with a
> fractional part representing the time.
> 
> For example 6pm today would be 16602.75
> 
> The only problem with this is that Stata has no
> date/time display format, so with %d display format
> this would just show "15jun2005".
> 
> David
> 
> -----Original Message-----
> From: Eric G. Wruck [mailto:ewruck@econalytics.com]
> Sent: 15 June 2005 14:41
> Subject: st: Date + Time of Day
> 
> 
> I have an Excel spreadsheet which includes a date
> column & dates are 
> in the following form:
> 
> 11/14/2000  16:27:00
> 
> That is, the date includes the time of day.  I've
> searched my Stata 9 
> manuals & all I can find on time is part of
> c(return) where one can 
> use c(current_time) but this doesn't seem
> relevant/helpful.
> 
> Is there a format that includes time as part of a
> date, or do I have 
> to parse this field out & create my own separate
> time variable?  What 
> do others do to handle this?
> 
> Thanks,
> 
> Eric



	
	
		
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
*
*   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