I created an SSIS Package that reads through existing files and makes changes/moves based on the file names and sheets. I have a C# Script Task that a co-worker wrote which is manually updated for the start and end of the fiscal year; however, we have others using this package so I would like to automate the Fiscal Year dates.
How can I get the starting and ending date of the current Fiscal Year based on today's date?
I did find Working out start of financial year and How to discover financial Year based on current datetime? however, I can't seem to get the top-voted answers to work. I'm using a Reference/Namespace of Microsoft.Office.Interop.Excel but I'm not sure if that makes a difference.
- Fiscal Year 2021 is 09/01/2020 to 08/31/2021
- Fiscal Year 2022 is 09/01/2021 to 08/31/2022
- Fiscal Year 2023 is 09/01/2022 to 08/31/2023
Today is 08/19/2022, the current Fiscal Year is 09/01/2021 - 08/31/2022, but when we hit 09/01/2022, it will change to 09/01/2022 - 08/31/2023.
This is what I use now, calling FYStart and FYEnd multiple times.
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
//Update Fiscal Year Here (YYY, MM, DD):
DateTime FYStart = new DateTime(2021, 09, 01);
DateTime FYEnd = new DateTime(2022, 08, 31);