Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Difference between dates in month

    I have dates %tdD_m_Y format and I want to create an indicator if they are exactly one month apart, that means 01 Feb 2001 to 01 Mar 2001 to 01 Apr 2001 is one month, not the number of days in between the dates.

    Is there a possibility (without Stata 17 date_diff function) to calculate this? Thank you.

  • #2
    What is one month later than 31 January? Than 31 March? And so on.

    Comment


    • #3
      Your question and your example are in conflict. The example you provide is that you have daily dates, and want dates a month apart. Does it mean that it can be any two dates so long as they are in adjacent months (e.g. March 1st to April 20th)? In this case, dates can be, effectively, only a day to as much as two months apart. Or must dates have the same have the same day of the month as well? In which case, how do you handle the mismatch days at the end of the month?

      If it's the first scenario, you simply need to work with monthly dates, which can obtained from a daily date using -mofd()-. The difference between any two adjacent months is then 1.

      Edit: crossed with #2

      Comment

      Working...
      X