如何使用sql查询数据和时间

时间:2016-02-02 07:02:55

标签: sql oracle

我想根据我的条件获取记录。

这是我的疑问。

select * from student where createdDate = '04/18/2013 03:24:49';

但我没有得到任何记录......

2 个答案:

答案 0 :(得分:2)

这不是您正在使用的有效日期时间字面值。请改用:

select * from student where createdDate = timestamp'2013-04-18 03:24:49';

答案 1 :(得分:2)

如果您的createdDate列的类型为date,则应使用to_date函数:

select * from student where createdDate = to_date('mm/dd/yyyy hh24:mi:ss', '04/18/2013 03:24:49');