months_since
Months since given date (truncated)
months_since(date)
Parameters
| Name | Type | Description |
|---|---|---|
date |
date | A date value (e.g., `first_trade_date`) |
Formula
Uses PostgreSQL's AGE function:
```
months_since = EXTRACT(YEAR FROM AGE(scan_date, date)) * 12
+ EXTRACT(MONTH FROM AGE(scan_date, date))
```
Examples
// Stocks that started trading within the last 6 months
months_since(first_trade_date) < 6;
// Stocks trading for at least 12 months
months_since(first_trade_date) >= 12;
Returns
Integer (complete calendar months)