oracle中日期查询

来源:百度知道 编辑:UC知道 时间:2024/09/28 14:20:47
我有条Sql语句
t_date 为DATE类型 有值 1987-6-7 19:4:20
select * from t_user where t_date = 我想匹配查找该日期,该怎么写语句
select * from t_user where t_date = to_date(这里该怎么写才对呢。)
我怎么查都查补出来。不好意思。我真没分了。在线等。大哥大姐帮帮忙啊
我使用to_date('1987-6-7 19:4:20','yyyy-mm-dd hh24:mi:ss')
方法查询了。但返回值是null 我存日期的时候是 new Date() 扔进去的。但我怎么匹配,都不正确,取不出该记录啊
估计格式不对,在Sqlplus 中显示1987-6-7 19:4:20 但我各种格式,都去不出来。
我用new Date() 跟存的时候相同的日期,也取不出来。那是怎么回事啊 我用的是hibernate 存的new Date()

create table apps.mytest
(tid date);

insert into apps.mytest values (to_date('1987-6-7 19:4:20','yyyy:MM:dd hh24:mi:ss'));

select * from apps.mytest where tid = to_date('1987-6-7 19:4:20','yyyy:MM:dd hh24:mi:ss');

to_date('1987-6-7 19:4:20','yyyy-mm-dd hh24:mi:ss')

要不你之前先运行
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

你以后不用to_date也行 直接='1987-6-7 19:4:20'也行

你查询一下to_date()函数的语法啊。
to_date(字符串,格式),如:
to_date('19870607190420','yyyymmddhh24miss')

select * from t_user where t_date = 我想匹配查找该日期,该怎么写语句
select * from t_user where t_date = to_date('1987-11-25 23:11:32','YYYY-MM-DD HH24-MI-SS')