简体   繁体   English

获取从特定日期到今天的SQL的周数

[英]Get Number of Weeks that have passed from a certain date to today SQL

Im trying to design a table with a column that has the total number of weeks that have passed from a static, hardcoded date, until today. 我试图设计一个表,其中的列具有从静态的硬编码日期到今天为止的总星期数。 For example, if the today is June 27, 2014, I want to find how many weeks have passed since May 31st, 2012; 例如,如果今天是2014年6月27日,我想找出自2012年5月31日起已经过去了几周; the program here would return 108 weeks. 该程序将返回108周。

Most results I have found have the week counter roll over at each new year, I would like to find something that keeps counting past 52. 我发现的大多数结果都在每个新年都有星期计数器,我想找到一些可以超过52的东西。

Im using a SYBASE ASE db if that is any help. 我正在使用SYBASE ASE数据库,如果有帮助的话。

You can use DATEDIFF function: 您可以使用DATEDIFF函数:

SELECT DATEDIFF(wk, '2012-08-20', '2014-06-27');

As described here or here : 如此此处所述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获得时间戳记日期为从今天起n天数的sql结果 - get sql results that have a timestamp date that is n number of days from today 从 PySpark 中的某个日期开始计算周数、天数和月数 - Count number of weeks, days and months from a certain date in PySpark 如何在SQL中计算与今天日期的天、周、月、年差异? - How to Calculate Days,Weeks,Month,Year difference from Today's Date in SQL? 从SQL中的所有年份获取日期=今天+2周到未来的行 - Getting rows where date=today+2 weeks to the future from all years in SQL 在使用SQL Server的情况下,如何使用星期数获取星期的开始日期和结束日期? - How to get the Starting date and ending date of weeks using week number in my case using SQL Server? 从数据库中获取从今天起两周的日期 - Get the dates of two weeks from today from database SQL Server从日期范围中获取天数,但不包括特定日期范围中的某些天 - SQL Server get number of days from date range excluding certain days from specific date range SQL需要从传递给查询的日期参数中减去某些时间 - SQL need to subtract certain time from date parameter passed into query SQL从今天开始按日期选择 - SQL select by date from today Linq to Sql今天仅从数据库获取日期数据 - Linq to Sql get today date only data from db
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM