DATE

fun DATE(unixepoch: Long): KQLiteColumn<KQLiteDate>

The DATE() function returns the date as text in this format: YYYY-MM-DD.

This overload accepts a Unix epoch timestamp. The Unix epoch is the number of seconds since 1970-01-01 00:00:00 UTC.

Example

// SELECT DATE(1761301829, 'unixepoch')
select(DATE(1761301829).unixepoch()).execute()

Return

A KQLiteColumn of type KQLiteDate representing the YYYY-MM-DD date.

Author

MOHAMMAD AZIM ANSARI

Parameters

unixepoch

A Long representing the Unix epoch timestamp.

See also


The DATE() function returns the date as text in this format: YYYY-MM-DD.

This overload accepts a Julian day number. A Julian day is the number of days since noon in Greenwich on November 24, 4714BC.

Example

// SELECT DATE(2460434.5)
select(DATE(2460434.5)).execute() // Result: "2024-05-04"

Return

A KQLiteColumn of type KQLiteDate representing the YYYY-MM-DD date.

Author

MOHAMMAD AZIM ANSARI

Parameters

julianday

A Double representing the Julian day number.

See also


The DATE() function returns the date as text in this format: YYYY-MM-DD.

This overload accepts a timestring. The timestring can be in various formats recognized by SQLite, such as:

  • YYYY-MM-DD

  • YYYY-MM-DD HH:MM

  • YYYY-MM-DD HH:MM:SS

  • YYYY-MM-DD HH:MM:SS.SSS

  • YYYY-MM-DDTHH:MM

  • and others, including 'now', 'start of month', etc.

Example

// SELECT DATE('2024-05-04 12:30:00')
select(DATE("2024-05-04 12:30:00")).execute() // Result: "2024-05-04"

// SELECT DATE('now')
select(DATE("now")).execute() // Result: current date

// Applying a modifier
// SELECT DATE('now', 'start of month', '+10 days')
select(DATE("now").startOfMonth().days(10)).execute()

Return

A KQLiteColumn of type KQLiteDate representing the YYYY-MM-DD date. The result can be null if the input string is not a recognized time string.

Author

MOHAMMAD AZIM ANSARI

Parameters

date

A String representing the date/time.

See also


fun DATE(year: Int, month: Int, day: Int): KQLiteColumn<KQLiteDate>

The DATE() function returns the date as text in this format: YYYY-MM-DD.

This overload constructs a date string from individual integer components for YEAR, MONTH, and DAY. It internally formats these components into a YYYY-MM-DD string that SQLite can parse.

Example

// SELECT DATE('2024-05-04')
select(DATE(2024, 5, 4)).execute()

Return

A KQLiteColumn of type KQLiteDate representing the YYYY-MM-DD date.

Author

MOHAMMAD AZIM ANSARI

Parameters

year

The year (e.g., 2024).

month

The month of the year (1-12).

day

The day of the month (1-31).

See also


The DATE() function returns the date as text in this format: YYYY-MM-DD.

This overload accepts a KQLiteColumn that contains a time string or a numeric value (like a Julian day number or Unix epoch time). This is useful for applying the DATE() function to a table column. It also supports applying modifiers to the date/time value before extracting the date part.

Example

// Inside KQLiteTable
val loginTime = timeColumn("Login") // Column stores "2024-05-04 15:30:00"

// SELECT DATE(loginTime) FROM Employees;
Employees
.select(Employees.loginTime)
.execute() // Result: "2024-05-04"

Return

A KQLiteColumn of type KQLiteDate representing the YYYY-MM-DD date.

Author

MOHAMMAD AZIM ANSARI

Parameters

column

A KQLiteColumn containing a date/time value or the result of a date/time modification.

See also