I have a variable in an imported dataset from Excel in this type and format:
type: double
format: %tcnn/dd/ccYY_hh:MM
Example:
DATE
4/25/2019 10:50
I need a variable with only the date 4/25/2019 (not the just the format %td, but the exact date with out time decimals such that time is removed and the date value is int)
I've tried the following:
gen newvar = dofd(date) result= 1.87e+12
gen newvar = string(date, "%td") = "1.87e+12" // in order to use e.g. date, substring or split to create a new date var.
Can someone explain what the problem is?
Kind regards,
Torben
Related Posts with Remove time in datetime variable
Error when doing graphing or using twoline commandI am a newbie in this field. I just used this Stata Program today. My current Stata ver is 14.1 and …
Firm fixed effects in SEM (unbalanced panel data)Dear all, that is my first post here on Statalist; I hope my request is in line with this forum's p…
Replace missing observations with the average of non-missing observationsDear Stata Users, Please, help me to resolve the following issue with reduced sample of data below:…
I need help to create a variableHi Statlistas! I am currently working on a dataset (tradedata from 2004--2016) where I have created…
Problems in running a pooled mean group estimation on a gravity datasetDear Stata users, I am trying to run a pooled mean group estimation on a dyadic dataset using the xt…
Subscribe to:
Post Comments (Atom)
0 Response to Remove time in datetime variable
Post a Comment