dateTimeColumn

Defines a nullable DATETIME column to store a dateTime.

This function creates and registers a column that stores dateTime values in the ISO-8601 format (YYYY-MM-DD HH:MM:SS or YYYY-MM-DDTHH:MM:SS.SSS). The underlying type is DATETIME. KQLite handles the conversion between this string representation and the KQLiteDateTime wrapper class, which provides type safety and convenient dateTime handling. The column is nullable by default.

Example:

object Logs : KQLiteTable("logs") {
// A nullable DATETIME column for a timestamp
val eventTimestamp = dateTimeColumn("event_timestamp")

// A non-null column with a default value of the current UTC dateTime
val createdAt = dateTimeColumn("created_at").notNull().default(CURRENT_TIMESTAMP)
}

Logs.quickInsert {
it.eventTimestamp.bind(DATETIME("now"))
it.createdAt.bind(DATETIME().now().localtime().seconds(-5))
}

Return

A KQLiteColumn instance representing the dateTime column, which can be further chained with constraints like notNull(), default(), etc.

Author

MOHAMMAD AZIM ANSARI

Parameters

name

The name of the column in the database.

See also