Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: best practice for dates and times

From   Nick Cox <>
To   "''" <>
Subject   RE: st: best practice for dates and times
Date   Mon, 21 Feb 2011 14:48:18 +0000

StataCorp itself is explicit and emphatic about recommending -double-s to hold date-times of the standard form in which the unit is milliseconds. That's been so since the new date-time system was introduced in Stata 10 in 2007. So, there is no issue or controversy in this particular case, as should be clear to anyone reading the documentation. See, e.g., help for dates_and_times. 


Liao, Junlin

Thank you for the reply. I had read and tried to use the blog post you suggested. That's why I finally choose to simply use string variable to import dates and times. Then you can forget about all the differences in different packages. One caveat, the issue of float vs. double also plays here. The float data type will misrepresent the times for certain values. The actual difference may be in seconds or mili-seconds, but there will be a visual difference when formatted in a meaningful way.

Nick Cox

On Sat, Feb 19, 2011 at 8:08 PM, Nick Cox <> wrote:
> The solution depends on the problem. Sometimes, it is easier to import
> numeric variables and then convert them to Stata dates. This can be
> very easy. See for example
> ware/
> Sometimes it is easier to import string variables (which I take it is
> what you mean by "text format") and convert them.
> I don't think there is any general better or best solution
> independently of how the dates are presented to you and what you want
> to do with them.
> Most of the complexity is apparent rather than real. The main
> difficulty is wading through the documentation to find the function
> you need. Once you've found a solution, it is easy to repeat it.
> Recently I was working with a dataset in which there were five data
> columns, Julian date, year, month and day and hour. The people I was
> working with didn't care about Julian date, so the main business was
> to apply -mdy()- and then -format-. Hour was just 0 or 12, so the most
> practical way forward was just to add 0.5 when the measurements were
> taken at midday.

> On Sat, Feb 19, 2011 at 7:50 PM, Liao, Junlin <> wrote:

I find that transfer data with dates and times is rather complicated with Stata. Lately I found that importing dates and times in text format and then converting with Stata functions would be the simplest approach. I'd like to hear if others have better solutions.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index