开发者

Oracle SQL Return all records within days of date

开发者 https://www.devze.com 2023-04-09 14:04 出处:网络
I am hoping that somebody can help me out with this question. The following SQL returns just the records in a given table that are specifically 20 days from current.

I am hoping that somebody can help me out with this question.

The following SQL returns just the records in a given table that are specifically 20 days from current.

Last_Mod_Date = TO_DATE(SYSDATE - 20)

Using 开发者_如何学编程similar theory can somebody help me determine how to return all records within the past 20 days range?

Thanks!


select 
  *
from
  table
where
  Last_Mod_Date >= trunc(sysdate-20);


SELECT * 
FROM MY_TABLE 
WHERE TO_DATE(my_ts_field) BETWEEN TO_DATE(SYSDATE-20) AND TO_DATE(SYSDATE)


Change the comparison to greater-than-or-equal:

Last_Mod_Date >= TO_DATE(SYSDATE-20)
0

精彩评论

暂无评论...
验证码 换一张
取 消