SQL TIMESTAMP DEFAULT CURRENT TIMESTAMP: How to remove miliseconds?

Viewed 96

Problem: When I print time in my HTML code it shows like this: 2020-05-31 03:29:50.617897

Code: https://i.stack.imgur.com/HTIXy.png

Question: How to get rid of decimal .617897? Thank you. I'm new to programming.

2 Answers

In Postgres, you can use date_trunc():

select date_trunc('second', current_timestamp)

Like this?

a = '2020-05-31 03:29:50.617897'
a = a.split('.')[0]
print(a)

Output:

'2020-05-31 03:29:50'
Related