# getQuarter

Industry: Core

## Signature

```ts
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`.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | zoneless ISO 8601 date or datetime string (e.g. "2024-06-15") |

## Options

**optionsArg**

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

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `fiscalYearStartMonth` | `number` | Required | The 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`](/gmt/reference/types/FiscalYearLabel/)) | Required | The calendar year that names a fiscal year. See `FiscalYearLabel`. |

## Returns

&#123; year, quarter &#125;, or null on invalid input

**Members**

| Member | Type | Description |
| --- | --- | --- |
| `year` | `number` | The year that names the quarter's year: the calendar year with no `options`, otherwise the one `yearLabel` picks. |
| `quarter` | `number` | The quarter of that year, 1 through 4. Quarter 1 begins in January with no `options`, and in the `fiscalYearStartMonth` month otherwise. |

## Related types

- [`FiscalYearLabel`](/gmt/reference/types/FiscalYearLabel/)

## Examples

```ts
import { getQuarter } from "@northguild/gmt/calendar/calculate";

getQuarter("2024-06-15") // { year: 2024, quarter: 2 }
```

## Source

[calendar/calculate/getQuarter.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/calendar/calculate/getQuarter.ts)
