Skip to content

getQuarter

  • The core functions, which every industry uses.
getQuarter(value: string, optionsArg?: { fiscalYearStartMonth: number; yearLabel: FiscalYearLabel; }): { year: number; quarter: number; } | null

Return the quarter value falls in, as a year and a quarter number.

  • With no options these are the calendar quarters: Q1 is January to March, and year is the calendar year.
  • With options, these are fiscal quarters. The fiscal year starts on day 1 of fiscalYearStartMonth, and yearLabel names it: "startYear", "endYear", or "majorityYear" (the calendar year holding the most of its days). Both are required, and there is no default. Start months 1 to 7 put most days in the start year, and 8 to 12 put most in the end year.
  • value must be zoneless — an ISO date or datetime, as isValidIsoDateLike accepts. See getIsoWeekDate for why a moment is not accepted here.
  • Returns null on invalid input, including options without both fields, a fiscalYearStartMonth that is not an integer from 1 to 12, or an unrecognised yearLabel.
ParameterTypeDescription
valuestringzoneless ISO 8601 date or datetime string (e.g. “2024-06-15”)

optionsArg

The fiscal year’s start month and the rule that names it

OptionTypeDefaultDescription
fiscalYearStartMonthnumberRequiredThe month the fiscal year starts in, 1 (January) through 12. A date before it belongs to the previous fiscal year, so with 4 the date "2024-03-31" is in that year’s Q4.
yearLabel"startYear" | "endYear" | "majorityYear" (FiscalYearLabel)RequiredThe calendar year that names a fiscal year. See FiscalYearLabel.

{ year, quarter }, or null on invalid input

Members

MemberTypeDescription
yearnumberThe year that names the quarter’s year: the calendar year with no options, otherwise the one yearLabel picks.
quarternumberThe quarter of that year, 1 through 4. Quarter 1 begins in January with no options, and in the fiscalYearStartMonth month otherwise.
import { getQuarter } from "@northguild/gmt/calendar/calculate";
getQuarter("2024-06-15") // { year: 2024, quarter: 2 }
output 

calendar/calculate/getQuarter.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.