Welcome! Please see the About page for a little more info on how this works.

0 votes
in On-Prem by

Hi guys,
I need to retrieve id's from all users in database that are older then 30 days, every user has creation date.,
(let [conn (client/get-conn)

  db (client/db)
  last-month (t/minus (t/now) (t/month 1))
  q '{:find  [(pull ?eid [*])]
      :where [[?eid :user/created]]}]

;;.............
)
I have last-month #inst date, I just dont know how to get all users "older" then 30 days.
I am new in datomic so,
if someone can help, thank you in advance...

1 Answer

0 votes
by

Howdy,

There are a few ways to do this depending on your needs and how deep you want to go. Datomic allows you to use functions in query. So in this case, you can use the greater than comparator with clauses like:

;Defining a date_start and date_end 30 day window [?e :user/created ?d] [(> ?d ?date_start)] [(< ?d ?date_end)]

We have an example using year here:

https://docs.datomic.com/on-prem/query/query.html#predicate-expressions

I hope this helps!

...