# isValidSqlOffsetDateTime

Industry: Core

## Signature

```ts
isValidSqlOffsetDateTime(value: string): boolean
isValidSqlOffsetDateTime(value: void | {} | null | undefined): boolean
isValidSqlOffsetDateTime(value: unknown): value is string
```

Return true when `value` is SQL `TIMESTAMP WITH TIME ZONE` text: SQL-92's `YYYY-MM-DD HH:MM:SS±HH:MM`, or a variant PostgreSQL `timestamptz`, SQL Server `datetimeoffset` or Oracle under an ISO `NLS_TIMESTAMP_TZ_FORMAT` print.

- True exactly when `parseSqlOffsetDateTime` returns a non-empty string for the same value. Both read through one core, so they cannot disagree.
- **Grammar:** SQL-92 §5.3 `<timestamp string>` and `<time zone interval>`, as `sqlOffsetDateTime` matches: a single space separator, a four-digit year `0001`–`9999`, two-digit month, day, hour, minute and second (seconds are required), an optional `.` followed by up to 9 fraction digits, then an offset `±HH`, `±HH:MM` or `±HH:MM:SS` (PostgreSQL's hour-only and seconds forms), with one optional space before it (SQL Server and Oracle). Offset hours `00`–`23` are GMT's rule, wider than SQL-92 (§5.3 Syntax Rule 25: −12:59 … +13:00), so that `+14:00` (SQL Server, MySQL, Oracle) is read; 24 and above is outside Temporal's offset grammar.
- Checks the calendar as well as the shape. `sqlOffsetDateTime` matches 30 February; this returns false for it.
- False for:
- a second of 60;
- a `T` separator or a `Z`, which `isValidInstant` and `isValidRfc3339DateTime` cover;
- text with no offset, which `isValidSqlDateTime` covers.
- A value that is not a string, a `String` object included, returns `false`. A `true` result narrows an `unknown` value to `string`.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | any value; a string is checked as a SQL offset timestamp literal |

## Returns

boolean indicating validity

## Examples

```ts
import { isValidSqlOffsetDateTime } from "@northguild/gmt/instant/validate";

isValidSqlOffsetDateTime("2024-03-15 14:30:00+00") // true
```

## Source

[instant/validate/isValidSqlOffsetDateTime.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/instant/validate/isValidSqlOffsetDateTime.ts)
