oracle中,有一个test表,表中有一date类型的date字段,如何根据条件查询date数据啊?

如题所述

以下每一句效果都一样:

1、Select * from a where date between to_date('2018-1-1', 'yyyy-mm-dd') and to_date('2018-8-1','yyyy-mm-dd')

2、Select * from a where date between to_date('2018/1/1', 'yyyy/mm/dd') and to_date('2018/8/1','yyyy/mm/dd')

3、Select * from a where date between to_date('2018-1-1', 'yyyy/mm/dd') and to_date('2018/8/1','yyyy-mm-dd')

扩展资料

数据库中Date与DateTime的区别

Date:代表xxxx年xx月xx日 只表示前面的日期,是SQL Server 2008新引进的数据类型。它表示一个日子,不包含时间部分,可以表示的日期范围从公元元年1月1日到9999年12月31日,只需要3个字节的存储空间。

DateTime:代表xxxx年xx月xx日xx时xx分xx秒 精确到时分秒,用于做时间戳,日期和时间部分,可以表示的日期范围从公元1753年1月1日00:00:00.000 到9999年12月31日23:59:59.997 ,精确到3.33毫秒,它需要8个字节的存储空间。

温馨提示:答案为网友推荐,仅供参考