D
D
Dnmesr2021-12-08 01:33:10
Python
Dnmesr, 2021-12-08 01:33:10

How to display the date in the format 11/01/1991 from the database?

I need to display the date from the database in the format 08.12.2021
When outputting, I get [('2021-12-07 15:50:24.069053',)]
How can I do this?

def get_reg_date(self, user_id):
        with self.connection:
             return self.cursor.execute("SELECT `date_registration` FROM `users` WHERE `user_id` = ?", (user_id,)).fetchall()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-12-08
@rozhnev

SELECT strftime('%d.%m.%Y', `date_registration`) AS `date_registration` FROM `users` WHERE `user_id` = ?

SQLite strftime fiddle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question