如何安排双周工作? [英] How can I schedule bi-weekly jobs?

查看:64
本文介绍了如何安排双周工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用要求用户安排定期发生的事件,这些事件可以每天,每周,每月或每两周发生一次.

My app requires users to schedule recurring events that can recur daily, weekly, monthly, or bi-weekly.

每两周一次,我的意思是每两周(14天)从创建时提供的任意日期值开始.

By bi-weekly, I mean every fortnight (14 days) starting from an arbitrary date value provided at the time of creation.

我的 jobs 表有两列支持此操作: job_frequency_id job_frequency_value .除了双周,我可以安排所有类型.

My jobs table has two columns to support this: job_frequency_id and job_frequency_value. I'm able to schedule all types except for bi-weekly.

第一个列是 job_frequencies 表的FK;它包含每日,每周,每月,每两周值. job_frequency_value 包含与频率相对应的值.

The first col is an FK to the job_frequencies table; it contains daily, weekly, monthy, bi-weekly values. The job_frequency_value contains the value corresponding to the frequency.

例如:如果一个作业的 job_frquency_id == 3 job_frequency_value == 10 ,则该作业将在该月的第10天运行.

For example: If a job has a job_frquency_id == 3 and job_frequency_value == 10, it will run every 10th day of the month.

如何在不影响数据库结构的情况下增加每两周一次的支持?我将使用 job_frequency_value col来存储14天时间段的开始日期,但是我不确定该计算将如何进行.

How do I add bi-weekly support without tampering with my db structure? I will use the job_frequency_value col to store the start date of the 14 day period, but I'm unsure of the calculation going forward.

推荐答案

说您的开始日期存储为名为"createdDate"的变量.

Say your starting date is stored as a variable named 'createdDate'.

nextFortnight = DateAdd("ww", job_frequency_value*2, createdDate);

这篇关于如何安排双周工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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