If try to create a reprex from what I understand here, I still get an integer column inside data.table
library(data.table)
dt <- data.table(x = as.IDate("2001-01-05"), y = as.IDate("2001-01-01"))
dt[, z := x -y]
dt
#> x y z
#> 1: 2001-01-05 2001-01-01 4
class(dt$x)
#> [1] "IDate" "Date"
class(dt$y)
#> [1] "IDate" "Date"
class(dt$z)
#> [1] "integer"
I obviously missed something.
Please, can you provide a reprex in order to help us help you ?