每周时间安排范围在几天之间
我制定了从周五晚上 2011-05-27 18:00 到周一早上的每周日程 2011-05-30 06:00。此时间表从2011-05-27开始每周执行。我们如何确定事件时间(2011-06-06 19:00)落在这个每周时间表之间?
更新
ID StartTime EndTime Recurrence TimeDifferenceInSeconds
1 2011-05-27 18:00 2011-05-30 06:00 1 216000
这里的复发是每周一次。
问候,
格里普蒂
I have a weekly schedule set from Friday evening 2011-05-27 18:00 to Monday morning
2011-05-30 06:00. This schedule executed on every week starts from 2011-05-27. How we can identify an event time (2011-06-06 19:00) falls between this weekly schedule ?
UPDATE
ID StartTime EndTime Recurrence TimeDifferenceInSeconds
1 2011-05-27 18:00 2011-05-30 06:00 1 216000
Here recurrence is every one week.
Regards,
Greepty
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决此问题的一种可能方法:
获取给定日期/时间与
StartTime
之间的整周数。将周数添加到
StartTime
以获取最晚的开始时间。计算最晚开始时间与给定日期/时间之间的差值。
检查该差异是否小于
TimeDifferenceInSeconds
。这就是它的实现方式:
这将返回
@Date
所属的所有时间表。更适合读者的版本:
A possible approach to this problem:
Get the number of whole weeks between the given date/time and
StartTime
.Add the number of weeks to
StartTime
to obtain the latest start time.Calculate the difference between the latest start time and the given date/time.
Check if that difference is less than
TimeDifferenceInSeconds
.And this is how it could be implemented:
This returns all the schedules that
@Date
falls on.A more reader-friendly version:
如果我理解正确的话,您想检查日期是否在周三和周三之间。周一。
在这种情况下,您只需执行
SELECT DATENAME(WEEKDAY, '6-Jun-2011')
即可,如果该日期正好是您得到答案的某一天,您只需检查时间即可那么组件。If I understand you correctly you want to check if a date will fall between a Wed & Mon.
In that case you can simply do a
SELECT DATENAME(WEEKDAY, '6-Jun-2011')
and if that falls on one of the days you have the answer, you will just have to check the time component then.