Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use date_trunc in PostgreSQL to truncate to 100 milliseconds?

Tags:

sql

postgresql

The date_trunc function uses field either millisecond or second, but millisecond is too small for me and second too large. I want something in between like 100 milliseconds (1/10 second).

How can I achieve this in PostgreSQL?

like image 289
Hello lad Avatar asked Sep 02 '25 15:09

Hello lad


1 Answers

I think you can do this with conversion. The following should give you tenths of a second:

select cast(datecol as timestamp(1))
like image 83
Gordon Linoff Avatar answered Sep 05 '25 04:09

Gordon Linoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!