Reputation: 24655
I have a date with a format like below, and I use R to convert it from string to date
date <- "20 Nov 2010 21:44:00:000"
strptime(date,"%d %b %Y %H:%M:%S")
I want to do it in Stata, but how? I tried this in Stata:
gen time_2 = date(time,"DMYhms#")
But it's not OK, why is that? Thanks.
Upvotes: 3
Views: 3359
Reputation:
The date
function converts dates expressed in days, months and years. For timestamps containing hours and seconds, you need the clock
function. The new variable should be in double precision
gen double time_2 = clock(time,"DMYhms#")
Upvotes: 5