计算条件的周数 [英] Calculating Number of week with a condition
问题描述
我正计划制作一个调度应用程序。根据商业逻辑,一周的第一天从你完成假期的那一刻开始。例如:如果我的假期结束了几年,我将从今天开始工作......这将算作我在工作的第一周但是实际上根据日历它的25.I将再次有资格在第40周度假,但不是来自实际的日历,而是来自计算我从上一次从一个回来的周数的系统。我需要一些关于如何计算它的帮助以及当新的一周是1时它是如何工作的。
有人可以建议我一个解决方案。谢谢。
I am planing to make a scheduling application. According to the business logic the first day of the week starts from the moment you finish your vacation..For Example: If my vacation ended years and I would start my work from today..It would be counted as my 1st week at work but actually according to the calender its the 25.I would be again eligible for a vacation on week 40 but not from the actual calender but from the system that is calculating my weeks from the last time i Came back from one. I need some help on how to calculate it and how it works when the new years week is 1.
Can some one please suggest me a solution. Thanks.
推荐答案
1。使用DateTime对象Subtract方法确定两个日期之间的天数。
2.将天数除以7以确定周数。
3.如果步骤2的结果等于或大于40,那么你有资格度假。
示例
1. Use DateTime object Subtract method to determine the number of days between two dates.
2. Divide the number of days by 7 to determine the number of weeks.
3. If the result of step 2 is equal to or greater than 40, then you are eligible for vacation.
Example
int weeks=0;
DateTime firstdayback = Convert.ToDateTime ("2013-06-01");
weeks = DateTime.Now.Subtract(firstdayback).Days / 7;
Console.WriteLine(weeks);
这篇关于计算条件的周数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!