[英]Oracle datetime compare based on format
In the Oracle, how to do this date compare if column type is datetime ? 在Oracle中,如果列类型是datetime,如何进行此日期比较? I want to keep the string format 'MM/dd/yyyy' .
我想保持字符串格式'MM / dd / yyyy'。
how to do this ? 这该怎么做 ?
Thanks 谢谢
select * from my_tbl
where mycol >= '07/11/2012'
Assuming that date means July 11th: 假设该日期表示7月11日:
select *
from my_tbl
where mycol >= to_date('07/11/2012', 'MM/DD/YYYY');
If that date should be November 7th: 如果那个日期应该是11月7日:
select *
from my_tbl
where mycol >= to_date('07/11/2012', 'DD/MM/YYYY');
Depending on how you fill in the values for mycol, you might want to get rid of the time part as well: 根据您填写mycol值的方式,您可能还想删除时间部分:
select *
from my_tbl
where trunc(mycol) >= to_date('07/11/2012', 'DD/MM/YYYY');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.