Reputation: 419
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 ?
Upvotes: 1
Views: 3196
Reputation: 550
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.
Upvotes: 1
Reputation: 1844
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
Upvotes: 0