Converting interval to the number of minutes: Assume we have the following table with two DATETIME columns. create table dt ( d1 datetime year to second, d2 datetime year to second); select d2, d1, ((extend(d2, minute to minute) - extend(d1, minute to minute)) || " ") + 60*((extend(d2, hour to hour) - extend(d1, hour to hour)) || " ") + 60*24*((extend(d2, day to day) - extend(d1, day to day)) || " ") + 60*24*30*((extend(d2, month to month) - extend(d1, month to month)) || " ") + 60*24*30*365*((extend(d2, year to year) - extend(d1, year to year)) || " ") mdif from dt;