Ecto.Query.API.datetime_add
You're seeing just the function
datetime_add
, go back to Ecto.Query.API module for more information.
Adds a given interval to a datetime.
The first argument is a datetime
, the second one is the count
for the interval, which may be either positive or negative and
the interval value:
# Get all items published since the last month
from p in Post, where: p.published_at >
datetime_add(^NaiveDateTime.utc_now(), -1, "month")
In the example above, we used datetime_add/3
to subtract one month
from the current datetime and compared it with the p.published_at
.
If you want to perform operations on date, date_add/3
could be used.
See Intervals for supported interval
values.