WHERE条件后面如果包含有日期的比较,不同数据库有不同的表达式。具体如下:
(1)如果是ACCESS数据库,则为:WHERE mydate>#2000-01-01#
(2)如果是ORACLE数据库,则为:WHERE mydate>cast('2000-01-01' as date)
或:WHERE mydate>to_date('2000-01-01','yyyy-mm-dd')
在Delphi中写成:
thedate= '2000-01-01';
query1.SQL.add('select * from abc where mydate>cast('+''''+thedate+''''+' as date)');
如果比较日期时间型,则为:
WHERE mydatetime>to_date('2000-01-01 10:00:01','yyyy-mm-dd hh24:mi:ss')