如何获取从 DateAdd 表达式返回的给定日期的周结束日期
不知道如何采用我当前的表达方式并获取本周的结束日期。
我当前的表达式返回日期,从今天算起一周。
DateAdd(DateInterval.WeekOfYear, 1, today())
我想做的是返回该周的结束日期(星期六)。
我需要向该表达式添加什么才能获得所需的结果?
谢谢!
好吧,看起来我已经明白了,但它很难看。谁能帮我简化这个?
这就是我将 Raj 的示例转换为表达式的结果:
“One Week Projected Backlog w/e”& DateAdd(日期间隔.Day, -1 * DatePart(DateInterval.WeekDay, (DateAdd(DateInterval.WeekOfYear, 1, 今天()))) + 7, (DateAdd(DateInterval.WeekOfYear, 1, 今天())))
Not sure how to take my current expression and get the week ending date of the week.
My current expression returns the date, one week from today.
DateAdd(DateInterval.WeekOfYear, 1, today())
What I want to do instead is return the end date (Saturday) of that week instead.
What do I need to add to this expression to get the desired result?
Thanks!
Okay, looks like I've got it but it's ugly. Can anyone help me streamline this?
Here's what I have, based on turning Raj's example into an expression:
="One Week Projected Backlog w/e "& DateAdd(DateInterval.Day,
-1 * DatePart(DateInterval.WeekDay,
(DateAdd(DateInterval.WeekOfYear, 1, today()))) + 7,
(DateAdd(DateInterval.WeekOfYear, 1, today())))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个,
我基本上计算了传入日期是一周中的哪一天,然后使用 -1 乘数软计算一周的开始,并通过添加 7 向前遍历到星期六。
当然,只有当您将 SQL Server 设置为从星期日开始的一周时,这才有效
对于 SQL Server 报告服务,我认为这应该适用于本周的星期六
对于下周的星期六
Try this
I basically calculated what day of the week then incoming date was, and then soft-computed the beginning of the week with the -1 multiplier, and traversed forward to the Saturday by adding 7 to it.
Of course, this will only work if you SQL Server is set to the week starting on Sunday
For SQL Server reporting services, I think this should work for Sat of current week
For Sat of next week
怎么样?
How about?