I have read "help datetime", but am still having trouble converting a string datetime variable into a stata variable. My input is formatted like "2007-12-19 00:19:33". After I format the output, I get years that were input as "2007" rendering as "207" in the formatted output. Any suggestions? Here is what I do
The same output occurs when I use the "date()" rather than the "clock()" function.
The conversion to stata date works, since format userregdate %td gives correct output
but using variation of the C, c, CCir cc as listed in the details portion of https://www.stata.com/manuals13/ddat...layformats.pdf doesn't give me the expected output.
bob kraut
Code:
gen double userregdate = clock(userregtime, "YMDhms") format userregdate %tccy/N/d list userregtime userregdate in 1/10 +----------------------------------+ | userregtime userregd~e | |----------------------------------| 1. | 2007-12-19 00:19:33 207/12/19 | 2. | 2007-10-29 14:50:22 207/10/29 |
Code:
. gen double userregdate = date(userregtime, "YMDhms") . format userregdate %tdcy/N/d . list userregtime userregdate in 1/10 +----------------------------------+ | userregtime userregd~e | |----------------------------------| 1. | 2007-12-19 00:19:33 207/12/19 | 2. | 2007-10-29 14:50:22 207/10/29 | +----------------------------------+
Code:
+---------------------------------+ | userregtime userre~te | |---------------------------------| 1. | 2007-12-19 00:19:33 19dec2007 | 2. | 2007-10-29 14:50:22 29oct2007 |
bob kraut
Comment