date - Generate year from %tc variable in Stata -
how can generate year stata variable format 09sep1943 00:00:00
, it's stored %tc
component?
this amply documented. see help datetime
, use yofd(dofc()
.
. clear . set obs 1 number of observations (_n) 0, 1 . gen double datetime = clock("09sep1943 00:00:00", "dmy hms") . format datetime %tc . gen year = yofd(dofc(datetime)) . l +---------------------------+ | datetime year | |---------------------------| 1. | 09sep1943 00:00:00 1943 | +---------------------------+
Comments
Post a Comment