当我将输入作为周数时,如何获得特定日期? [英] How Do I Get Particular Dates When I Give Input As Week Number..?

查看:93
本文介绍了当我将输入作为周数时,如何获得特定日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友..



i有桌子上有没有日期的桌子..



问题是:如果我给出周数表示我想要从该表中特定的周日期...



例如:



我的桌子



日期|姓名



10/10/15 | rama

12/10/15 | shiva

11/09/15 | sitha

25/07/15 |克里希纳





如果我将周数作为45表示..我应该得到..:第45周日期如10/10 / 15至17/10/15日期应该到来。

Hello friends..

i had table having no.of dates in that table..

Question is :if i give week number means i want particular week dates from that table..

For example:

My table

dates | names

10/10/15 | rama
12/10/15 | shiva
11/09/15 | sitha
25/07/15 | Krishna


here if i give week number as 45 means..i should get ..: 45th week dates like 10/10/15 to 17/10/15 dates should come.

推荐答案

您可以使用 DATEPART()找到一年中的一周并传递 WEEK 作为第一个参数。

试试这个 -



You can find week of the year using DATEPART() and passing WEEK as first parameter.
Try this-

SELECT Dates,Names
FROM MyTable
WHERE DATEPART(WEEK,Dates)=45





希望,它有帮助:)



更新:

回应OP的评论 -





Hope, it helps :)

UPDATE:
In response to OP's comment-

SELECT Dates,CASE WHEN DATEPART(WEEK,Dates)=45 THEN Names ELSE "0" END AS Names
FROM MyTable


这篇关于当我将输入作为周数时,如何获得特定日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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