Need to determine which quarter a date falls in for financial reporting or analytics? This guide shows you how to use the Quarter Calculator API to detect quarters, get quarter boundaries, and handle custom fiscal year configurations.
What are Fiscal Quarters?
A fiscal quarter is a three-month period used for financial reporting and business analysis. A year is divided into four quarters: Q1, Q2, Q3, and Q4. Quarters help businesses track performance, set goals, and report earnings.
For a calendar year starting in January:
- Q1: January - March
- Q2: April - June
- Q3: July - September
- Q4: October - December
Calendar Year vs Fiscal Year
Not all companies use a calendar year for their fiscal year. Many organizations start their fiscal year in different months:
- US Federal Government: October 1st (FY starts in Q4 of calendar year)
- Apple Inc: October 1st
- Microsoft: July 1st
- UK Tax Year: April 6th
Using the Quarter Calculator API
TinyFn provides a flexible endpoint for quarter calculations:
GET https://api.tinyfn.io/v1/time/quarter
Headers: X-API-Key: your-api-key
{
"date": "2024-05-15T00:00:00.000Z",
"quarter": 2,
"quarter_name": "Q2",
"fiscal_year": 2024,
"quarter_start": "2024-04-01T00:00:00.000Z",
"quarter_end": "2024-06-30T23:59:59.999Z",
"days_in_quarter": 91,
"days_remaining": 46
}
Parameters
| Parameter | Type | Description |
|---|---|---|
date |
string | Date in ISO 8601 format (required) |
fiscal_start_month |
integer | Month when fiscal year starts (1-12). Default: 1 (January) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/time/quarter?' + new URLSearchParams({
date: '2024-05-15'
}),
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const result = await response.json();
console.log(result.quarter); // 2
console.log(result.quarter_name); // "Q2"
console.log(result.quarter_start); // "2024-04-01T00:00:00.000Z"
Python
import requests
# Example with custom fiscal year starting in October
response = requests.get(
'https://api.tinyfn.io/v1/time/quarter',
params={
'date': '2024-01-15',
'fiscal_start_month': 10 # Fiscal year starts in October
},
headers={'X-API-Key': 'your-api-key'}
)
result = response.json()
print(result['quarter']) # 2 (Jan-Mar is Q2 when FY starts in Oct)
print(result['fiscal_year']) # 2024 (FY2024 started Oct 2023)
cURL
curl "https://api.tinyfn.io/v1/time/quarter?date=2024-08-15&fiscal_start_month=7" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Financial Reporting: Generate quarterly financial statements
- Sales Tracking: Track quarterly sales targets and performance
- Budget Planning: Allocate and monitor quarterly budgets
- Analytics Dashboards: Group data by quarter for trend analysis
- Tax Preparation: Calculate quarterly tax payments
Best Practices
- Document your fiscal year: Make clear which fiscal year configuration you use
- Use quarter boundaries: Leverage quarter_start and quarter_end for date range queries
- Consider timezone: Quarter boundaries may differ by timezone
- Handle year transitions: Be careful with dates near fiscal year boundaries
Try the Quarter Calculator API
Get your free API key and simplify your quarterly calculations.
Get Free API Key