Meridianmeridian

SQL Timestamp with Microseconds

datetime.timestamp.sql_microseconds

Space-separated date and time with 6-digit microsecond precision. Default output of Python str(datetime.now()) and PostgreSQL TIMESTAMP. Distinct from iso_8601_microseconds by space (not T) separator.

Domain
datetime
Category
timestamp
Casts to
TIMESTAMP
Scope
Universal

Try it

CLI
$ finetype infer -i "2024-01-15 14:30:00.123456"
→ datetime.timestamp.sql_microseconds

DuckDB

Detect
SELECT finetype('2024-01-15 14:30:00.123456');
-- → 'datetime.timestamp.sql_microseconds'
Cast expression
strptime({col}, '%Y-%m-%d %H:%M:%S.%f')
-- Format: %Y-%m-%d %H:%M:%S.%f
Safe cast pipeline
-- Normalise and cast in one step
SELECT TRY_CAST(finetype_cast(my_column) AS TIMESTAMP) AS clean_value
FROM my_table
WHERE finetype(my_column) = 'datetime.timestamp.sql_microseconds';

JSON Schema

finetype schema datetime.timestamp.sql_microseconds
{
  "$id": "https://meridian.online/schemas/datetime.timestamp.sql_microseconds",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Space-separated date and time with 6-digit microsecond precision. Default output of Python str(datetime.now()) and PostgreSQL TIMESTAMP. Distinct from iso_8601_microseconds by space (not T) separator.",
  "examples": [
    "2024-01-15 14: 30: 00.123456",
    "2019-12-31 23: 59: 59.000000",
    "2023-06-01 08: 15: 30.789012"
  ],
  "maxLength": 26,
  "minLength": 26,
  "pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{6}$",
  "title": "SQL Timestamp with Microseconds",
  "type": "string",
  "x-finetype-broad-type": "TIMESTAMP",
  "x-finetype-format-string": "%Y-%m-%d %H:%M:%S.%f",
  "x-finetype-transform": "strptime({col}, '%Y-%m-%d %H:%M:%S.%f')"
}

Examples

2024-01-15 14:30:00.1234562019-12-31 23:59:59.0000002023-06-01 08:15:30.789012

Aliases

sql_micro