表:
我正在使用MYSQL。
tax_year_end_changes | CREATE TABLE `tax_year_end_changes` (
`id` int(11) NOT NULL auto_increment,
`company_id` int(11) NOT NULL,
`date` date NOT NULL default '1970-01-01',
`reason` enum('Fiscal_Year_End','Control_Change') collate utf8_unicode_ci NOT
NULL default 'Fiscal_Year_End',
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `company_id` (`company_id`,`date`,`reason`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
此表包含公司的会计年度结束列表。当公司会计年度结束时,表格刚刚结束新的会计年度。默认会计年度结束时间从1970年开始存储。更改将从更改日期生效。示例数据:
从tax_year_end_changes中选择company_id,date,reason;
1 1970-12-31 Fiscal_Year_End
1 2011-01-31 Fiscal_Year_End
3 1970-01-31 Fiscal_Year_End
4 1970-11-30 Fiscal_Year_End
此处,公司1的财政年度截至2010年12月31日。2011年,FYE将更改为1月31日。因此,对于该公司,有效的FYE是:
2010年12月31日 2011年1月31日 2012年1月31日 。 。
我想在给定日期范围的情况下生成有效FYE列表。具体地,
我有一个开始日期和月数。
我想生成类似的东西:
用例1
Start Date: 2010-11-01
Number of Months: 3
company_id,month,tax_year_end_date
4 11 2010-11-30
1 12 2010-12-31
3 01 2011-01-31
1 01 2011-01-31
用例2
Start Date: 2011-11-01
Number of Months: 3
company_id, month, tax_year_end_date
4 11 2011-11-30
3 01 2011-01-31
1 01 2011-01-31
注意:请注意公司1中的使用案例2,2011-12-31如何显示,因为该年份不再有效。