【发布时间】:2017-08-30 10:32:57
【问题描述】:
我正在创建一个存储过程来显示基于周数、月数和年数的日期范围内的某些记录。
例如:
Month = 4 [APRIL]
Week = 2 [Week 2 for APRIL]
Year = 2017
输出应该是:[Start day should be Sunday]
STARTDATE | END DATE
4-2-2017 | 4-8-2017
到处搜索,这个已经很难了。
编辑: 我提供了一个示例查询供参考
@Month int,
@Year int,
@WeekNumber int
SELECT
(start date of the week based on week num, month, year) as DATE1,
(end date of the week based on week num, month, year) as DATE2
WHERE
StartDate = (start date of the week based on week num, month, year)
EndDate = (end date of the week based on week num, month, year)
【问题讨论】:
-
谢谢。但不幸的是,没有回答我的问题。需要的参数只有周数、月数和年份,而不是完整日期。
-
您能否包含您将在何处执行查询的示例数据
-
@CurseStacker - 请查看我的编辑。
-
不,表中的实际数据,您需要获取。
标签: sql sql-server sql-server-2008 tsql date