I have a table with a field of type bigint. This field store a timestamp. I want to date format the field like this :
to_char( bigint_field,'DD/MM/YYYY HH24:MI:SS')
I get the following error :
ERROR: multiple decimal points État SQL :42601
Instead, you should use to_char to format the date when you query it, or format it in the client application. Like: SELECT to_char("date", 'DD/MM/YYYY') FROM mytable; e.g.
The TO_DATE function in PostgreSQL is used to converting strings into dates. Its syntax is TO_DATE(text, text) and the return type is date. The TO_TIMESTAMP function converts string data into timestamps with timezone. Its syntax is to_timestamp(text, text) .
The date format for the date data type in PostgreSQL is yyyy-mm-dd . This is the format used for both storing data and for inserting data.
1) Get the current date To get the current date and time, you use the built-in NOW() function. However, to get the date part only (without the time part), you use the double colons (::) to cast a DATETIME value to a DATE value. The result is in the format: yyyy-mm-dd .
TO_CHAR(TO_TIMESTAMP(bigint_field / 1000), 'DD/MM/YYYY HH24:MI:SS')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With