Skip to content
Prev 68514 / 398506 Next

How to transform the date format as "20050425"

On 25 Apr 2005 at 15:18, Yong Wang wrote:

            
If the format really is always like that you can use this:
require(date) # gives you date handling
x <- as.character(20050425)
date <- 
mdy.date(as.numeric(substr(x,5,6)),as.numeric(substr(x,7,8)),\ 
as.numeric(substr(x,1,4)))

(You'll have to remove the line wrapping there, the "\" is where I 
put a break in!)

Good luck!

Chris