isValidSqlDateTime
Signature
Section titled “Signature”isValidSqlDateTime(value: string): booleanisValidSqlDateTime(value: void | {} | null | undefined): booleanisValidSqlDateTime(value: unknown): value is stringReturn true when value is a real SQL timestamp literal without a time zone: the YYYY-MM-DD HH:MM:SS[.fff] value of a standard SQL TIMESTAMP or a MySQL/SQLite DATETIME column. It checks one date-and-time value, not a SQL statement.
- True exactly when
parseSqlDateTimereturns a plain string for the same value: the validator and the parser read through one internal core, so the two cannot disagree. - Grammar: SQL-92 §5.3
<timestamp string>and the ODBCtsescape, assqlDateTimematches: a single space separator, a four-digit year0001–9999, two-digit month, day, hour, minute and second (seconds are required), and an optional.followed by up to 9 fraction digits. - Checks the calendar as well as the shape. The
sqlDateTimepattern proves the shape alone, so it matches a day that does not exist: 30 February, 29 February in a common year and 31 June are false here. - False for a second of 60: GMT rejects leap seconds.
- Plain only. A
Tseparator, aZand an offset are false: SQL’s offset-carryingTIMESTAMP WITH TIME ZONEliteral is checked byisValidSqlOffsetDateTime. - Read the value with
parseSqlDateTime; write one withformatSqlDateTime. - A value that is not a string, a
Stringobject included, returnsfalse. Atrueresult narrows anunknownvalue tostring.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | any value; a string is checked as a SQL timestamp literal |
Returns
Section titled “Returns”boolean indicating validity
Examples
Section titled “Examples”import { isValidSqlDateTime } from "@northguild/gmt/plain/validate";
isValidSqlDateTime("2024-03-15 14:30:00") // trueSource
Section titled “Source”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.