星期几时如何找到第一天.在SQL Server中给出 [英] how to find first day when week no. is given in sql server

查看:56
本文介绍了星期几时如何找到第一天.在SQL Server中给出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

星期几时如何找到第一天.在sql server中给出

我有一个星期编号= 14如何找到星期的拳头日期


Thanks

how to find first day when week no. is given in sql server

i have a week no=14 how to find fist date of week


thanks

推荐答案

这将为您提供当年第一周的第一天的日期(使用ISO规则)-然后,您可以使用DATEADD来抵消您的需要一周.
This will give you the date of the first day of week one of the current year (using ISO rules) - you can then use DATEADD to offset to your required week.
SET DATEFIRST 1
DECLARE @week int  set @week = 1
DECLARE @year int  set @year = 2007

SELECT DATEADD (week, @week, DATEADD (year, @year-1900, 0)) - 4 - DATEPART(dw, DATEADD (week, @week, DATEADD (year, @yr-1900, 0)) - 4) + 1


这篇关于星期几时如何找到第一天.在SQL Server中给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆