--1.假设你的数据库中,日期的存储为8位的年月日: 20110101 20111112 ... --sql select * from tableName where date = to_char(sysdate, 'yyyyMMdd')--2.假设你的数据库中,日期存储为带有时分秒的timestamp型,而你想抽出年月日相同的日期,不计较时分秒20110101142330 ...--sql select * from tableNmae where substr(date,0,8) = to_char(sysdate, 'yyyyMMdd')
select * from tablename where date like to_date(to_char(sysdate,'yyyymmdd'),'yyyymmdd');因为你的date是日期型(date型的),格式不匹配,无法比较,如果你的date只是存储年月日,可以用LS的,比较简单。
20110101
20111112
...
--sql
select * from tableName where date = to_char(sysdate, 'yyyyMMdd')--2.假设你的数据库中,日期存储为带有时分秒的timestamp型,而你想抽出年月日相同的日期,不计较时分秒20110101142330
...--sql
select * from tableNmae where substr(date,0,8) = to_char(sysdate, 'yyyyMMdd')
请问用LIKE应该怎么写呢?
select * from tablename where instr(to_char(sysdate,'yymmdd'),date)>0
select * from tablename where instr(to_char(sysdate,'yymmdd'),date)>0