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: RE: dates and elapsed time

From   "Michael N. Mitchell" <>
Subject   Re: st: RE: dates and elapsed time
Date   Mon, 09 Aug 2010 18:51:54 -0700

In addition to Kieran's helpful answer, I would also recommend

which contains a quick rundown of dates in Stata.

I hope that helps,

Michael N. Mitchell
Data Management Using Stata      -
A Visual Guide to Stata Graphics -
Stata tidbit of the week         -

On 2010-08-09 4.05 PM, Kieran McCaul wrote:

You need to use the -date- function.

di %d date("17-Mar-85", "DM19Y")

So, if you have dates stored as strings in two variables, date1 and

gen firstdate = date(date1, "DM19Y")
gen seconddate = date(date2, "DM19Y")
format firstdate seconddate %d

gen n_days = seconddate - firstdate

-----Original Message-----
[] On Behalf Of Kirsten Beyer
Sent: Tuesday, 10 August 2010 6:42 AM
Subject: st: dates and elapsed time


I am relatively new to STATA and have been unsuccessful in formatting
dates, then calculating the number of days between them.

Dates are in the following format: 17-Mar-85

Any advice?

*   For searches and help try:

*   For searches and help try:
*   For searches and help try:

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