Since you did not give us your dataset to work with, I contrived this one for exposition purposes.
ds =
Dataset[
{Association["a" -> 1, "b" -> "x",
"date" -> DateObject[{2019, 4, 14, 20, 14, 47.767113}, "Instant", Gregorian", -4.]],
Association["a" -> 2, "b" -> "y",
"date" -> DateObject[{2019, 4, 15, 20, 14, 47.767451}, "Instant", "Gregorian", -4.]],
Association["a" -> 3, "b" -> "z",
"date" -> DateObject[{2019, 4, 16, 20, 14, 47.767678}, "Instant", "Gregorian", -4.]],
Association["a" -> 4, "b" -> "x",
"date" -> DateObject[{2019, 4, 17, 20, 14, 47.7679}, "Instant", "Gregorian", -4.]],
Association["a" -> 5, "b" -> "y",
"date" -> DateObject[{2019, 4, 18, 20, 14, 47.768123}, "Instant", "Gregorian", -4.]],
Association["a" -> 6, "b" -> "z",
"date" -> DateObject[{2019, 4, 19, 20, 14, 47.768346}, "Instant", "Gregorian", -4.]]}];
With this dataset, I can add a column of date differences given in minutes starting with the following code.
rows = Length @ ds;
dates = ds[All , "date"] // Normal
diffs =
Association["differce" -> #] & /@
Prepend[
Table[DateDifference[dates[[i]], dates[[i + 1]], "Minutes"], {i, rows - 1}],
Quantity[0., "Minutes"]]
Evaluation gives a list of differences expressed as associations.
{<|"difference" -> Quantity[0., "Minutes"]|>,
<|"difference" -> Quantity[1440., "Minutes"]|>,
<|"difference" -> Quantity[1440., "Minutes"]|>,
<|"difference" -> Quantity[1440., "Minutes"]|>,
<|"difference" -> Quantity[1440., "Minutes"]|>,
<|"difference" -> Quantity[1440., "Minutes"]|>}
The list can be appended to ds
as new column having the key "difference" with the following one-liner.
ds = Join @@@ Transpose @ {ds // Normal, diffs} // Dataset

Table
instead ofFor
+Print
.Print
is meant only for display, not for returning values. $\endgroup$ – Henrik Schumacher Apr 14 '19 at 22:59