DATEDIF (Start Date, End Date, Unit)
- Syntax:
DATEDIF(start_date, end_date, "unit")
- About: Calculates the difference between two dates in days, months, or years.
- Example: To find out how many months a subscription has been active, use
DATEDIF(activated_at, today(), "M")
to get the total number of months between the start date and today.
EOMONTH (Start Date, Months)
- Syntax:
EOMONTH(start_date, months)
- About: Returns the last day of the month a specified number of months away from the start date.
- Example: To find the end date of the current billing cycle, use
EOMONTH(today(), 0)
to get the last day of the current month.
MONTH (Date)
- Syntax:
MONTH(date)
- About: Extracts the month from a given date as a number between 1 (January) and 12 (December).
- Example: To categorize transactions by month, use
MONTH(transaction_date)
to convert a date to a month number.
YEAR (Date)
- Syntax:
YEAR(date)
- About: Extracts the year from a given date as a four-digit number.
- Example: To filter data from the current year, compare
YEAR(due_date)
withYEAR(today())
to check if the years match.
TODAY (Current Date)
- Syntax:
today()
- About: Returns the current date, with no time component.
- Example: To check if a subscription is due today, compare
today()
with thenext_billing_at
date to trigger an alert if they match.