客户一个数据库表中一列为[DateAndTime],但却为文本类型。日期格式为2010年09月12日。我想实现日期的区间选择, select XXXX from xxxx where DateAndTime between 2010年09月12日 and 2010年10月01日。没效。该怎么办? (表格中平均每个相同的日期占10行左右,即是每个日期的id不是唯一的,但我只根据日期区间选择)
select XXXX from xxxx where DateAndTime between Convert(datetime, '2010年09月12日', 120) and Convert(datetime, '2010年10月01日', 120) 主要就是 先把字符串类型的转换成 日期类型 再查询大概是这个思路
select XXXX from xxxx where DateAndTime between cdate('2010年09月12日') and cdate( '2010年10月01日') 试试这个
select * from XXXX where to_date(replace(replace(replace(DateAndTime ,'年','-'),'月','-'),'日',''),'yyyy-mm-dd') > to_date('2010-09-12','yyyy-mm-dd')and to_date(replace(replace(replace(DateAndTime ,'年','-'),'月','-'),'日',''),'yyyy-mm-dd')<to_date('2010-10-01','yyyy-mm-dd')
Convert(datetime, '2010年09月12日', 120)
and Convert(datetime, '2010年10月01日', 120) 主要就是 先把字符串类型的转换成 日期类型 再查询大概是这个思路
cdate('2010年09月12日')
and cdate( '2010年10月01日') 试试这个
给你感受下。