Announcement

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

  • Destringing date and time variable

    Hello all,

    I'm having trouble destringing a date and time variable. I've attached a picture to give you an idea of how they appear. Any help would be appreciated!

    Thank you,
    Jama
    Attached Files

  • #2
    You don't want to destring. You want human-readable form (HRF) to Stata internal form (SIF).

    Code:
    gen double wanted = clock(arrival, "DMYhms")
    format wanted %tc
    See
    Code:
    help datetime

    Comment


    • #3
      Justin Niakamal is bang on. destring would be quite wrong here. Removing the colons could only make the dates harder to read and removing the month text JAN FEB and so on would just destroy needed information.

      For an overview of this territory stressing that date strings need date functions, see https://www.stata-journal.com/articl...article=dm0098

      Comment


      • #4
        Stata's "date and time" variables are complicated and there is a lot to learn. Along with the article recommended by Nick Cox, if you have not already read the very detailed Chapter 24 (Working with dates and times) of the Stata User's Guide PDF, do so now. If you have, it's time for a refresher. After that, the help datetime documentation will usually be enough to point the way. You can't remember everything; even the most experienced users end up referring to the help datetime documentation or back to the manual for details. But at least you will get a good understanding of the basics and the underlying principles. An investment of time that will be amply repaid.

        All Stata manuals are included as PDFs in the Stata installation and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu.

        Comment

        Working...
        X