[英]Getting rows where date=today+2 weeks to the future from all years in SQL
I have a table in a SQL Server with a bunch of columns.我在 SQL Server 中有一个包含一堆列的表。 I'd need to pull the data straight to excel and only include these three columns with all rows where 'Date' includes values from today + 2 weeks to the future from every year.
我需要将数据直接提取到 excel 中,并且只包括这三列,其中“日期”包括从今天 + 2 周到每年未来的所有行。
I'm really a beginner with SQL, so a help with the query would save me hours.我真的是 SQL 的初学者,所以查询帮助可以节省我的时间。
Date![]() |
Zipcode![]() |
Country![]() |
---|---|---|
2021-12-07 00.00.00.000 ![]() |
1725 ![]() |
GB![]() |
2022-14-07 00.00.00.000 ![]() |
1366 ![]() |
GB![]() |
2020-12-06 00.00.00.000 ![]() |
1677 ![]() |
GB![]() |
2022-12-05 00.00.00.000 ![]() |
9747 ![]() |
GB![]() |
In Oracle would be this:在 Oracle 中是这样的:
select [column names you want] from table_name where date > sysdate+14;
In SQL Server:在 SQL Server 中:
select [column names you want] from table_name where date >
DATEADD(week, 2, DATEDIFF(date, 0, date));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.