如何计算下周六到下周六的可用周日? [英] How to calculate the next available Sunday to the following Saturday?

查看:112
本文介绍了如何计算下周六到下周六的可用周日?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个sql查询,我正在尝试确定下一个可用的星期日上午12:00到下周六晚上11:59,我有以下查询:


选择dateadd(dd,((datediff(dd,'''17530107'',MAX(payrolldate))/ 7)* 7)+7,''17530107'')AS [星期日]来自dbo.payroll

其中payrollran =''不''


这给了我下一个星期天没有时间,但我仍然没有接下来的星期六。有人可以帮忙吗?


谢谢


道格

解决方案

减法结果一分钟。


Rabbit,


我只得到一个结果,我需要两个。一个用于下一个星期日,第二个结果应该是下一个星期六。


对于星期日之后的星期六,采取星期日的日期时间,增加7天,减去一分钟。

I am writing a sql query and I''m trying to determine the next available Sunday at 12:00 AM through the next Saturday 11:59 PM and I have the following query:

select dateadd(dd, ((datediff(dd, ''17530107'', MAX(payrolldate))/7)*7)+7, ''17530107'') AS [Sunday] from dbo.payroll
where payrollran = ''No''

That gives me the next available Sunday with no time but I still don''t have the following Saturday. Can someone please assist?

Thank you

Doug

解决方案

Subtract a minute from the result.


Rabbit,

I''m only getting one result, and I need two. One for the next Sunday, and the second result should be the following Saturday.


For the saturday following the sunday, take the sunday datetime, add 7 days, subtract one minute.


这篇关于如何计算下周六到下周六的可用周日?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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