# parseSqlDateTime

Industry: Core

## Signature

```ts
parseSqlDateTime(value: string): string
```

Parse a SQL timestamp literal without a time zone — the `YYYY-MM-DD HH:MM:SS[.fff]` form of standard SQL `TIMESTAMP` and MySQL/SQLite `DATETIME` columns — into a plain ISO 8601 datetime string.

- **Grammar:** SQL-92 §5.3 `<timestamp string>` and the ODBC `ts` escape, as `sqlDateTime` matches: a space separator, a four-digit year `0001`–`9999` (no sign, no expanded year), two-digit month, day, hour, minute and second (seconds are required), and an optional `.` followed by up to 9 fraction digits.
- **Plain only.** SQL's offset-carrying `TIMESTAMP WITH TIME ZONE` literal has its own reader, `parseSqlOffsetDateTime`.
- The fraction is written as `Temporal.PlainDateTime#toString` writes it: trailing zeros are dropped (`.500` → `.5`, `.000` → none), and a `.` with no digits is dropped. `Temporal.PlainDateTime.from` proves the value is a real calendar date and time.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | SQL timestamp literal (e.g. "2024-03-15 14:30:00") |

## Returns

plain ISO 8601 datetime string, or "" on invalid input

## Examples

```ts
import { parseSqlDateTime } from "@northguild/gmt/plain/parse";

parseSqlDateTime("2024-03-15 14:30:00") // "2024-03-15T14:30:00"
```

## Source

[plain/parse/parseSqlDateTime.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/plain/parse/parseSqlDateTime.ts)
