1

When I am trying to insert a date with timestamp to my postgresql table, I am getting the below error:

ERROR: invalid input syntax for type double precision: "2011-05-31 02:20:30"

The query is below. Here the ID field is a text and the REPORTED_DATE field is a double precision.

insert into my_table ("ID", "REPORTED_DATE")  values('ID8033','2011-05-31 02:20:30');

How do I need to change the query to be able to insert it ? Or do I need to change the datatype of the REPORTED_FIELD column accordingly ?

2 Answers 2

1

You need to change the datatype of REPORTED_FIELD, use timestamp, or change the string to get the time (seconds, milliseconds) of date and change the field to integer.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, it worked. I could solve it as :alter table my_table alter column "REPORTED_DATE" type timestamp with time zone using to_timestamp('REPORTED_DATE', 'YYYY-MM-DD HH24:MI:SS');
0

double precision is a floating-point number: https://www.postgresql.org/docs/9.5/static/datatype.html.

You are looking for timestamp: https://www.postgresql.org/docs/9.5/static/datatype-datetime.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.