SQL中的相对日期计算算法
我需要计算作业的下个月运行时间,可以使用两个参数指定,这两个参数可以从
参数 1 中获取值:
1 表示星期日,2 表示星期一,3 表示星期二,4 表示星期三,5 表示星期四,6 表示星期五,7 表示星期六,8 表示白天,9 表示工作日,10 表示周末
参数 2:
1 代表第一,2 代表第二,4 代表第三,8 代表第四,16 代表最后
根据这两个参数,您可以指定运行时间,例如该月的第一个工作日或该月的最后一个星期日。
如何使用知道当前日期、para1 和 para2 的存储过程得出此日期
I have a requirement to calculate the next monthly run time of a job which can be specified using two parameters which can take values from
Parameter 1:
1 for Sunday, 2 for Monday, 3 for Tuesday, 4 for Wednesday, 5 for Thursday, 6 for Friday, 7 for Saturday, 8 for Day, 9 for Weekday, 10 for Weekend day
Parameter 2:
1 for First, 2 for Second, 4 for Third, 8 for Fourth, 16 for Last
Based on these two parameters you can specify a run time like First weekday of the month or Last sunday of the month.
How do I arrive at this date using a stored procedure which will know current date, para1 and para2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
未测试。但我希望这会有所帮助。如果日期已经过期,您可能希望返回 null。
not tested. but i hope this helps. And you may want to return null if the date is already overdue.
这可能会让你开始。摘自:如何获取一个月的第 N 个工作日
这不完全是您要寻找的内容,但应该涵盖主要部分。
This might get you started. Taken From: How-to-get-the-Nth-weekday-of-a-month
It's not exactly what you are looking for, but should cover the main part.