Using the Calendar Assistant in inmydata
The Calendar Assistant in inmydata provides programmatic access to your organization’s financial calendar. It lets you map any date to standard financial periods like year, quarter, month, and week—based on your configured inmydata calendar.
This is especially useful for automation, reporting, and analytics workflows where aligning data with business time periods is critical.
Prerequisites
Before using the Calendar Assistant, make sure:
You’ve set up your
.envfile with the following variables:INMYDATA_TENANTINMYDATA_CALENDAR
You’ve installed the
inmydataPython package andpython-dotenv:
Example: Working with Financial Periods
The example below demonstrates how to:
Initialize the Calendar Assistant
Get today's financial year, quarter, month, and week
List the active financial periods for today
import os
from datetime import date
from dotenv import load_dotenv
from inmydata.CalendarAssistant import CalendarAssistant
load_dotenv()
# Get today's date
today = date.today()
# Initialize the Calendar Assistant with tenant and calendar name
assistant = CalendarAssistant(os.environ['INMYDATA_TENANT'], os.environ['INMYDATA_CALENDAR'])
# Get the current financial year
print("The current financial year is: " + str(assistant.get_financial_year(today)))
# Get the current financial quarter
print("The current financial quarter is: " + str(assistant.get_quarter(today)))
# Get the current financial month
print("The current financial month is: " + str(assistant.get_month(today)))
# Get the current financial week
print("The current financial week is: " + str(assistant.get_week_number(today)))
# Get the current financial periods
print("The current periods are:")
print(assistant.get_financial_periods(today))
# Get the date range for the current financial month
response = assistant.get_calendar_period_date_range(assistant.get_financial_year(today), assistant.get_month(today), CalendarPeriodType.month)
if response is not None:
print("The current financial month date range is: " + response.StartDate.strftime("%A, %B %d, %Y") + " to " + response.EndDate.strftime("%A, %B %d, %Y"))What Are Financial Periods?
Financial periods are defined in your inmydata calendar and can include:
Financial Year (e.g. FY24)
Quarter (e.g. Q3)
Month (e.g. Apr-24)
Week Number (e.g. W12)
Custom periods configured by your organization
? All functions in the
CalendarAssistanttake adatetime.dateobject and return integers or structured data representing the corresponding period.
When to Use This
Embedding calendar-aware logic in automation scripts
Aligning user inputs or system dates with business reporting periods
Simplifying date-to-period translation for dashboards or agents
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article