Announcement

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

  • create the day before a date

    Hello!

    I'm still working with dates and now have a new problem. If I have a date 22dec2014, I want 1 day before that, which is 21dec2014, I could do
    Code:
    gen date_pre1 = mdy(month(date), day(date)-1, year(date))
    that works if the date is not the first day of a month. If I have 01jul2017, I wonder how to get 30jun2017? The code above would generate a missing value.

    Thanks a lot for any help.

  • #2
    Code:
    gen date_pre1 = date-1
    format date_pre1 %td

    Comment


    • #3
      Thanks Clyde, this is so simple! I really overthink...

      Comment

      Working...
      X