--oralce to_date 例子
create table wutest(
x date ,
y number(4)
);
--到秒
insert into wutest(x,y) values(to_date('2005-12-1 23:23:12','yyyy-mm-dd hh24:mi:ss'),1);
--到分
insert into wutest(x,y) values(to_date('2005-12-1 23:23','yyyy-mm-dd hh24:mi'),1);--天
insert into wutest(x,y) values(to_date('2005-12-1','yyyy-mm-dd'),1);commit ;
create table wutest(
x date ,
y number(4)
);
--到秒
insert into wutest(x,y) values(to_date('2005-12-1 23:23:12','yyyy-mm-dd hh24:mi:ss'),1);
--到分
insert into wutest(x,y) values(to_date('2005-12-1 23:23','yyyy-mm-dd hh24:mi'),1);--天
insert into wutest(x,y) values(to_date('2005-12-1','yyyy-mm-dd'),1);commit ;
格式都是一样么?用to_char可以吗?
如 convert(char(10),getdate(),120) 结果是yyyy-mm-dd
select substring(convert(char(10),getdate(),120),6,5) --时间