我的数据库中,时间类型是yyyy-mm-dd,现在想要转换成yyyymmdd,有几万条数据,如何进行转换呢?
如下图,数据中时间格式有两种,我束手无策啦。
谢谢~
|
楼主: xwan5667
|
4347
13
[数据管理求助] 菜鸟求助stata数据清理时间变量问题 |
|
大专生 56%
-
|
回帖推荐hplcdadong 发表于8楼 查看完整内容 See, your second post is quite different from the first one (25jun2013 is different from 2013/06/25). Here is the solution:
gen date_n=date(substr(trim(admission_date),1,10), "YMD")
replace date_n=date(trim(admission_date), "DMY") if missing(date_n)
format date_n %tdCCYY/NN/DD
hplcdadong 发表于3楼 查看完整内容 Assume your original "admission date" is string variable when you import it into Stata, based on your presented data here, try the following (replace "admission_date with your own real date variable):
gen date_n=date(substr(admission_date,1,10), "YMD")
format date_n %tdCCYY/NN/DD
| ||
|
|
| ||||||||||||||
|
where there is a will there is a way
|
|
| ||
| ||
加好友,备注jltj京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明


