# formatSwiftDate

Industry: Finance

:::caution[Unreleased]
Not in `@northguild/gmt` 1.21.0 on npm yet. It is on `main` and ships in the next release.
:::

## Signature

```ts
formatSwiftDate(value: string): string
```

Write an ISO 8601 date as a SWIFT MT value date, `YYMMDD`. The inverse of `parseSwiftDate`.

- **What it writes.** The six-digit value date (`<DATE2>`, `6!n`) that SWIFT's rule covers: field 32A of MT 910, and fields 30 and 32A of category 1 and 2 messages other than the common group messages n92, n95 and n96. Two digits each of year, month and day.
- **`value`** is a date, as `isValidDate` accepts it, in the ISO calendar. A date-time, an instant or a non-ISO calendar returns `""`: a date-time names a calendar date only in a zone, so take the date in the zone you mean first.
- **The year must be 2001 to 2060**, the range SWIFT accepts for those value dates. Any other year returns `""`: written as two digits, it would read back as another year or be refused with error T50. So `parseSwiftDate(formatSwiftDate(d))` reads back as the same date, written `YYYY-MM-DD` (`d` itself when `d` is already written that way).
- **Sources.** SWIFT _Standards MT General Information_ (Standards MT November 2025), §6.3.1 Dates and §6.3.6 Value Date Ordering: https://www2.swift.com/knowledgecentre/rest/v1/publications/usgi_20250718/2.0/usgi_20250718.pdf
- Returns `""` for a non-string argument.

## Parameters

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

## Returns

the `YYMMDD` string ("240615"), or "" on invalid input

## Examples

```ts
import { formatSwiftDate } from "@northguild/gmt/finance/format";

formatSwiftDate("2024-06-15") // "240615"
```

## Source

[finance/format/formatSwiftDate.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/finance/format/formatSwiftDate.ts)
