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
Regression with timeHello everyone, I would like to run a regression with date for example as follows: Inflation=GDP+y…
Stop Stata from processing current commandAfter starting a lengthy regression, I realized a mistake. How do I tell Stata to stop doing what i…
Using a global within regress Code: global wc_mvp = 10 regress percent_funded novelty_score if wc > $wc_mvp returns invali…
Three-year average of a variableHello all, I want to create a variable which is defined as the annual decile rankings of the three-y…
Crude incidence rate stratified by calendar yearI have estimated the overall crude incidence rate of diabetes in people with hypertension (the study…
Subscribe to:
Post Comments (Atom)
0 Response to Remove time in datetime variable
Post a Comment