--> 测试数据: #tb if object_id('tempdb.dbo.#tb') is not null drop table #tb go create table #tb (id int,name datetime) insert into #tb select 1,'2011-1-11 18:23:23' select * from #tb id name ----------- ----------------------- 1 2011-01-11 18:23:23.000(1 行受影响)
--不知道你语句是怎么写的! create table b(dat datetime) insert into b select '2010-1-12' goinsert into b select '2010-1-1 18:30' select * from bdrop table bdat ----------------------- 2010-01-12 00:00:00.000 2010-01-01 18:30:00.000
if object_id('tempdb.dbo.#tb') is not null drop table #tb
go
create table #tb (id int,name datetime)
insert into #tb
select 1,'2011-1-11 18:23:23' select * from #tb
id name
----------- -----------------------
1 2011-01-11 18:23:23.000(1 行受影响)
--不知道你语句是怎么写的!
create table b(dat datetime)
insert into b
select '2010-1-12'
goinsert into b select '2010-1-1 18:30'
select * from bdrop table bdat
-----------------------
2010-01-12 00:00:00.000
2010-01-01 18:30:00.000
df = DateFormat.getDateTimeInstance();
然后再用insert into DepotMission (orderID,stateID,depotMissionTime,billID) values ("+orderID+",1,"+df.format(new Date()).toString()+",1) 其他没问题,df.format(new Date()).toString() 得到的结果是“2011-1-11 18:33:58”
create table tb(dt datetime)
insert into tb values('2011-1-11')
insert into tb values('2011-1-11 18:23:23')
goselect * from tbdrop table tb/*
dt
------------------------------------------------------
2011-01-11 00:00:00.000
2011-01-11 18:23:23.000(所影响的行数为 2 行)
*/
String str1 = d1.format(now);
类似。 我找到问题了。日期型必须要加单引号,我在页面中把语句改为
insert into DepotMission (orderID,stateID,depotMissionTime,billID) values ("+orderID+",1,"+“‘”+df.format(new Date()).toString()+"’,1)就可以了呵呵,基本功太烂了