表名:A
時間字段:ddatetime(datetime類型)
查詢2003-2004年6月7日-7月8日數據。
select * from A where (extract(year from ddatetime) between 2003 and 2004)
and (extract(month from ddatetime) between 6 and 7)
and (extract(day from ddatetime) between 6 and 7)
extract只能取到日。小時,或者到秒,需要to_char。
查詢2003-2004年6月7日-7月8日12時到20時數據。
select * from A where (extract(year from ddatetime) between 2003 and 2004)
and (extract(month from ddatetime) between 6 and 7)
and (extract(day from ddatetime) between 6 and 7) and (to_char(ddatetime,'HH24') between 12 and 20)
以上查詢在oracle可運行。
(澳門)炒家、用家 樓市拉鋸戰
13 年前
沒有留言:
張貼留言