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

Re: st: Date + Time of Day

From   Joseph Coveney <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: Date + Time of Day
Date   Wed, 15 Jun 2005 23:14:52 +0900

Eric G. Wruck wrote:

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?


Take a look at -odbc load- (-help odbc-).  If your operating system supports 
ODBC, then the -datestring- option to -odbc load- allows you to input date-time 
data formats from ODBC sources into Stata as strings that include both date and 
time.  Microsoft provides an Excel ODBC driver that you can use with Stata.

Of course, it'll arrive in Stata as a string variable and, because Stata does 
not have a date-time data-type, if you want to do arithmetic on the values, 
then you'll still need to parse them into separate date and time variables.  
There are functions that facilitate this--Nick Cox wrote an FAQ that he posted 
on the List some time ago that surveys time functions in Stata: . . . highly recommended.

Joseph Coveney

*   For searches and help try:

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