Announcement

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

  • DataTime formatting

    Hi, need a help here,

    I have a variable like this:

    Code:
    clear
    input str25 createdat
    "2021-11-24T16:47:22+00:00"
    "2021-11-24T19:14:59+00:00"
    "2021-11-25T11:39:15+00:00"
    "2021-11-25T11:40:04+00:00"
    "2021-11-29T12:58:02+00:00"
    "2021-11-29T13:48:38+00:00"
    "2021-11-29T19:59:05+00:00"
    end
    How do I convert it to numerically encoded Stata dateTime format, without splitting the string variable ?

    thks,





  • #2
    Code:
    gen double wanted = clock(createdat, "YMD#hms#")
    format wanted %tc
    In general, wherever a string date or clock variable has extraneous characters that need to be ignored, the # character is used in the string argument that describes the contents of the string variable.

    Comment

    Working...
    X