0

I have a value for time as 2017-05-25T18:44:56 . The following is my table structure

CREATE TABLE aaaaaa (
    enroll_id bigserial primary key,
    time timestamp with time zone NOT NULL        
);

When i insert the above value into time column its throws the following error { error: syntax error at or near "T18"}

How can i solve this? Please share your ideas. Thanks in advance.

My insert Query:

var query = 'Insert Into aaaaa (enroll_id, time,) values ('+item.EnrollNumber+', '+item.time+')';
Subburaj
  • 5,114
  • 10
  • 44
  • 87

1 Answers1

0

You have to surround time value with quotes.

Insert Into aaaa (enroll_id, time) values (19, '2017-05-25T18:44:56')

and query construction in javascript should look similiar to

var a=15;
var b='2017-05-25T18:44:56';
var query = "Insert Into aaaaa (enroll_id, time,) values ("+a+", '"+b+"')";

Check here Put quotes around a variable string in JavaScript

Lemjur
  • 338
  • 3
  • 11
  • im constructin query like this `var query = 'Insert Into aaaaa (enroll_id, time,) values ('+item.EnrollNumber+', '+item.time+')';` How can i modify this to form the above query – Subburaj Jul 27 '17 at 07:34