DATESUBTRACT
Subtracts a specified number of days, months, years, hours, minutes, or seconds from a given date
Syntax
DATESUBTRACT(date, num, unit)
Arguments
date
: The Unix timestamp (number) representing the starting date.num
: The number of units to subtract.unit
: The unit of time to subtract ("year", "month", "day", "hour", "minute", "second").
Example
DATESUBTRACT(1678886400, 7, "day") → Returns 1678281600 (March 10, 2023, 7 days before March 17, 2023).
DATESUBTRACT(1678886400, 1, "month") → Returns 1676380800 (February 17, 2023, 1 month before March 17, 2023).
Usage Notes:
- The
date
argument must be a valid AnyDB Date - The
unit
argument must be one of the following strings: "year", "month", "day", "hour", "minute", "second". - The function operates in UTC timezone.
- The return value is a Unix timestamp representing the resulting date.