Do the previous records already exist? Or do you have to create them?
If they exist and the previous month has a number of days in it already, do you
overwrite the existing value, add to it (up to 30), etc.
What is the structure of the previous records?
Were does the starting number of days get entered? In a record, in a variable?
How do you know which month to start with?
Do you have multiple years of data? If not, what do you do if you start with
February (max 28 or 29 days) and have a number like 125? Just give Feb and Jan
30 each and ignore the other 65 days?
All those problems (and others) can be solved with VBA or perhaps in an SQL
query, but until you define how you handle each situation, there is no use
developing a solution.
Some starting hints.
StartDays\30 will tell you the number of whole months
StartDays Mod 30 will tell you the number of remaining days.
13 - (StartDays \30) could tell you the number of the first month that gets 30
days. Depends on your rules.
If StartDays Mod 30 = 0 Then you don't need to add any partial 30 day period.
If the records already exist, then you would need something like
UPDATE YourTable
SET NumberDays = 30
WHERE MonthNumber Between [SomeCurrentMonthNumberFromSomewhere] and
[SomeCurrentMonthNumberFromSomewhere] +1 - (StartDays \30)
AND EmployeeID = [????SomeValueFromSomewhere????]
Hi all,
Suppose we have 12 months a year and each year has only 30 days.
For example a worker until month 8 has worked for 170 days and I'd like to
fill in 5 months(150=5*30 days) and 20 days salary for him.(170=5*30+20)
Month 8 30 day
Month 7 30 day
Month 6 30 day
Month 5 30 day
Month 4 30 day
Month 3 20 day
Is there a VBA code or query for this problem?