简体   繁体   English

从SQL中的所有年份获取日期=今天+2周到未来的行

[英]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 2021-12-07 00.00.00.000 1725 1725 GB国标
2022-14-07 00.00.00.000 2022-14-07 00.00.00.000 1366 1366 GB国标
2020-12-06 00.00.00.000 2020-12-06 00.00.00.000 1677 1677 GB国标
2022-12-05 00.00.00.000 2022-12-05 00.00.00.000 9747 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.

相关问题 获取从特定日期到今天的SQL的周数 - Get Number of Weeks that have passed from a certain date to today SQL 在sql msaccess中将年和周转换为日期 - convert years and weeks to date in sql msaccess 将SQL中所有项目的项目日期范围划分为工作周行 - Split project date range into rows of work weeks for all projects in SQL 如何在SQL中显示将来的日期和今天的日期 - How to display future date and today date in SQL 在 SQL 查询(BigQuery)中,如何从具有 UTC tz 的列中获取今天在莫斯科 tz 中 CreatedDatetime 的所有行? - In SQL query (BigQuery) How get all rows where CreatedDatetime is Today in Moscow tz from column with UTC tz? PHP sql查询,选择所有日期不到60天的日期 - PHP sql query, select all where date is less than 60 days from today 如何在SQL中计算与今天日期的天、周、月、年差异? - How to Calculate Days,Weeks,Month,Year difference from Today's Date in SQL? 从今天开始选择大于5年前的所有年份 - select all years that greater than 5 years ago from year today (SQL Server)试图计算从今天开始的连续会计年度的计算 - (SQL Server) Trying to figure out a calculation for consecutive fiscal years from today's date SQL从今天开始的日期减去加上天数 - SQL where Date from today minus and plus days
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM