Announcement

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

  • Date-variable: Extracting day-of-month as numeric

    Hello everyone,

    I would highly appreciate your help with the following:

    I have a date-variable in the format such as "31jan2001" (type: long, Format: %td). For my further analysis, I would like to create a new variable which displays only the day-of-month, so the "31" as a numeric number.

    I read several posts but I did not find a solution how to do this...

    As always, thanks for your support!

    Samuel

  • #2
    Use the function day() as documented in help datetime or under help date functions

    Code:
    . di day(mdy(1, 31, 2001))
    31
    For your unnamed daily date variable

    Code:
    gen day = day(whatever)

    Comment


    • #3
      perfect, thank you so much!

      All the best,

      Samuel

      Comment

      Working...
      X