数据类型Varchar2到日期格式

时间:2019-01-08 11:42:10

标签: oracle varchar2

我正在编写SQL代码以提取有效开始日期大于或等于24/09/2018 00:00:00的数据。我的有效起始日期数据类型在varchar2中。下面是我正在使用的代码:

TO_DATE(TRUNC(effective_start_date),'DD/MM/YY') >='24/09/2018 00:00:00')

2 个答案:

答案 0 :(得分:0)

尝试一下:

select case
 when  Cast(effective_start_date as dateTime) >= cast('2018/09/24 00:00:00' as dateTime) 
 then 1 --your business
 else 
 0  --your business
 end

答案 1 :(得分:0)

您可以尝试以下方法:

trunc(to_date( effective_start_date, 'DD/MM/YYYY HH24:MI:SS' )) >= to_date('24/09/2018 00:00:00', 'DD/MM/YYYY HH24:MI:SS')

将日期时间存储为varchar是非常错误的。

相关问题