Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在DATE列中保存了一个日期。我尝试获取那些自该日期以来更高的行,大约一年,两年等。
DATE
,是我的应用程序中的一个参数year。two years是否可以通过查询获取这些行,或者我应该在应用层上这样做?
year
two years
SELECT * FROM your_table WHERE the_date_column > current_date - interval '2' year
只需将 2 替换为应用程序中的参数值即可。