Saturday - last edited Saturday
Hello BluePrism Community,
I have a scenario where I need to calculate a "Ten Days Duration" (TDD) code for a given date, and I need to do this for the current, previous, and next 10 TDDs in one go. The TDD code follows a consistent rule, starting from December 21st of each year and continuing until December 20th of the following year.
Here is the TDD mapping I need:
TDD Mapping (for each year):
December 1 to December 10, 2024 → 202435
December 11 to December 20, 2024 → 202436
December 21 to December 31, 2024 → 202401
January 1 to January 10, 2025 → 202502
January 11 to January 20, 2025 → 202503
January 21 to January 31, 2025 → 202503 (same as previous period due to the 10-day range rule)
The Task:
Calculate the current TDD for a given date.
Calculate the previous 10 TDDs (i.e., the last 10 periods before the current date).
Calculate the next 10 TDDs (i.e., the upcoming 10 periods after the current date).
Requirements:
Year transitions: Handle year changes automatically (e.g., from December 31 to January 1).
Month variations: Account for varying month lengths (28/29/30/31 days).
Leap years: Ensure leap year handling.
TDD Range Logic: TDDs follow the same rule every year, starting from December 21st of each year and ending on December 20th of the next year, creating 36 distinct 10-day periods (e.g., 202435, 202436, etc.).
Edge cases: Proper handling for dates falling on the boundary of a TDD range.
Goal:
I need an approach that:
Automatically calculates the current, previous, and future TDDs.
Dynamically adjusts the TDD range for each year, ensuring it doesn’t fail even when the year transitions or when months have varying lengths.
Accounts for leap years and other edge cases.
Could someone suggest the most robust approach to calculate the current, previous, and future TDDs in one go, ensuring it works across year transitions, different month lengths, leap years, and properly follows the TDD range rule?
Any help or suggestions would be greatly appreciated!
Monday
Why did you post this twice? I can't identify a good reason for that. It seems like you provided more information here and less information over here: Duration calculation logic for Ten days period - SS&C Blue Prism Community.
And honestly it sounds like you're just asking other people to do your job for you. What have you tried that didn't work for you? Do you have working code and would like it to run faster? Do you have partially working code that doesn't account for one of the special aspects such as leap year? You have plenty of information about what you need but zero about what you have tried.
Monday
The TDD logic seems off or not completely explained. Based on your examples it looks like it is actually just the 1st of the month to 10th, 11th to 20th, then 21st to end of the month, and just always starts on Dec 21st. If it is actually 10 days then your examples do not seem correct to me as the actual days in each differ and you would not always get 36 distinct periods.
So depending on the TDD logic really depends on the calculation you need to use. Outside of the logic you say the last 10 and the next 10 durations which I would just say don't calculate those "in one go" calculate them a head of time, or in the next year data is required, at some duration and store somewhere (db, csv, excel, whatever your preference) and look it up when required.
As david pointed out not sure what you have tried so not sure what would work.