错误:插入时出现接近时间格式错误。
示例:
--Table "Test"
create table test
(
name varchar(10),
date1 timestamp,
time1 timestamp
);
-- Insertion
insert into test values('xyz','03/03/2014','02:03:04');
最佳答案
“timestamp”类型包含时间和日期。您正在尝试分别插入日期和时间。使用日期和时间类型:
--Table "Test"
create table test
(
name varchar(10),
date1 date,
time1 time
);
-- Insertion
insert into test values('xyz','03/03/2014','02:03:04');
或者,只使用一个字段:
--Table "Test"
create table test
(
name varchar(10),
datetime timestamp
);
-- Insertion
insert into test values('xyz','03/03/2014 02:03:04');
我推荐第二种方法,因为可用的运算符和函数集要大得多,而且比较时间戳更容易。
关于Postgresql:我们如何使用时间戳将时间和日期仅插入到变量中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22140542/