Announcement

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

  • Date to numeric value

    Hi you guys,

    I have a problem with my data. I want to convert my date which is defined as DDMMYYYY to a numeric value but I don't know how to do this in Stata. Could someone help me out with this? I would really appreciate your help.

    Greeting,
    Rik

  • #2
    Hello Rik,

    Assuming that your date data is in a string variable, and it follows the DDMMYYYY format completely, you can use the date() function. This solution is also assuming you mean that you're looking for the %td date format.

    Something like...
    Code:
    gen numeric_date = date(string_date, "DMY")
    format numeric_date %td
    Look up
    Code:
    help f_date
    for more information.

    Comment


    • #3
      I'd add a reference to

      Code:
      help datetime
      It's all documented for you to read.

      Comment

      Working...
      X