The same question is asked here without a solution, [How to avoid fread() importing date info as IDate?](https://stackoverflow.com/q/67326349/1972786)

The old question was not very specific and was mixing some other issue alongside, Also it did not contain a reprex that I present here. Hence I am improving the question. Please donot mark it as duplicate :-)

The question is: Whenever I read a csv file containing a date column using `data.table:: fread` it changes the class of the `Date` column to `IDate`. How do I avoid this and keep it as Date format?

```r
library(data.table)
library(magrittr)
dt <- data.table(datecol = seq(Sys.Date(),by = "1 day",length.out = 3))
# let's confirm the format of the column is Date
str(dt)
#> Classes 'data.table' and 'data.frame':   3 obs. of  1 variable:
#>  $ datecol: Date, format: "2022-05-10" "2022-05-11" ...
#>  - attr(*, ".internal.selfref")=<externalptr>
# Now we write it into a file and read back using fwrite and fread
fwrite(dt,"tmpoutput.csv")
fread("tmpoutput.csv") %>% str
#> Classes 'data.table' and 'data.frame':   3 obs. of  1 variable:
#>  $ datecol: IDate, format: "2022-05-10" "2022-05-11" ...
#>  - attr(*, ".internal.selfref")=<externalptr>
# as you see the date format changes to IDate

```

Created on 2022-05-10 by the [reprex package](https://reprex.tidyverse.org) (v2.0.1)

This is not a huge problem but it needs one extra line of code everytime after a file is read i.e. `dt[,datecol:=as_date(datecol = as_date(datecol)]` so that rbind with a similar DT does not fail.

Is there a simpler way to avoid this, as it is a potential bug reason if we forget to do a type conversion later?