Q
Q
Qwestyuio4272022-02-22 14:38:51
PostgreSQL
Qwestyuio427, 2022-02-22 14:38:51

How to make time for postgresql?

I want to make a loan in a tg bot with a return - 3 days. How to make it so that every second all users who have a credit take a second? Can this be done in postgresql? Or how? (if my bot is on the server)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2022-02-22
@Akela_wolf

Record the date and time of the loan repayment in the database. And when outputting data to the user - calculate the rest of the time.

V
Vyacheslav Uspensky, 2022-03-08
@Kwisatz

Record the time of issue (well, let it be created_at) and return (expired_at) of the loan in timestamptz
second as alter table my_table add expired_at timestamptz generated always as ( created_at + interval '3 day');
Then look for rotten ones through select * where is_payed=false and
expired_at

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question