Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Difference in dates |
Date | Sun, 15 Jul 2012 21:44:58 +0100 |
Evidently if the dates are really the same, the result of calculating the difference should be 0. So this question is immediately bounced back to you: what are your grounds for your contradictory statement? What makes you say these two things? Note that either or both being assigned a daily date format is purely a cosmetic matter, as that just affects what is displayed, and is only indirectly related to what the value _is_, meaning _is stored as_. Otherwise put, non-integers will display as if they were (integer) dates if assigned a daily date format. . di %td mdy(7,15,2012) + 0.5 15jul2012 . di %td mdy(7,15,2012) + 0.6 15jul2012 . di %td mdy(7,15,2012) + 0.9 15jul2012 . di %td mdy(7,15,2012) + 1 16jul2012 You should look at the date variables using a non-date display format. Presumably at least one has been calculated incorrectly at some previous point. Nick On Sun, Jul 15, 2012 at 8:48 PM, Lisa Davis <lisadavismd@gmail.com> wrote: > I'm comparing two date variables (coded daily) in Stata by subtracting one from a second, which gives a difference in days. When the dates are the same, the result is 0.5 rather than 0. Does anyone have an explanation? * * 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/