Ciaren

Date difference

Date difference — dateDifference

Compute the difference between two date columns (end − start) as a number, in a chosen unit.

Use cases

  • Days between order_date and ship_date.
  • Customer age in years from birth_date to today (with a constant column).
  • Hours elapsed between two timestamps.

What it does

Both columns are parsed to datetimes, then end − start is converted to the chosen unit and written to a new numeric column. The result is fractional (e.g. 1.5 days). Unparseable dates become null instead of failing the run.

Configuration

Config keyTypeRequiredDescription
start_columnstringYesThe earlier date column
end_columnstringYesThe later date column (result is end − start)
unitstringNo (default days)days, hours, minutes, seconds, or weeks
new_columnstringYesName of the result column

Generated Python code

df_2 = df_1.assign(days_between=lambda _d: (pd.to_datetime(_d['ship_date'], errors='coerce') - pd.to_datetime(_d['order_date'], errors='coerce')).dt.total_seconds() / 86400)

Tips & common mistakes

  • The result is end − start, so a later start gives a negative number.
  • If a column is plain text, this node parses it; for full control over the format use Parse dates first.

See also