Subtract to date

Description

This function calculates the difference between two dates in a specified unit of time.

Parameters

  • date1 (string): The first date to be used in the calculation. The date should be formatted as a string in the format YYYY-MM-DD.
  • number (number): a number representing the amount of time to substract to the date.
  • inputLocale (string, optional): The locale to be used for the input dates. Accepted values are: "pt", "nl", "en", "de", "ja", "zh", "fr". If this parameter is not provided, the default value is "en".
  • unit (string, optional): The unit of time to be used for the calculation. Accepted values are: "days", "hours", "months", "years", "minutes", "seconds", "milliseconds". If this parameter is not provided, the default value is "seconds".

Examples

Subtract few hours to a date:

sub-to-date("2022-01-01", 3, unit="hours")

Output: 2021-12-31T21:00:00

Subtract two years:

sub-to-date("2022-01-01", 2, unit="years")

Output: 2020-01-01