Bookmark and Share

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


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

st: RE: dates and elapsed time


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   st: RE: dates and elapsed time
Date   Tue, 10 Aug 2010 07:05:06 +0800

...

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
date2:

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

gen n_days = seconddate - firstdate






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

Hello,

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

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

Any advice?

KB
*
*   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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index