STRFTIME
fun STRFTIME(format: String, column: KQLiteColumn<out DateTimeModifier?>? = null): KQLiteColumn<KQLiteDateTime>
The STRFTIME() function returns a string representing the date and time, formatted according to the format string. The optional second argument is a time string, which defaults to 'now' if omitted.
This function is highly versatile for custom date/time formatting. The format string can contain various substitutions, such as:
%Y: Year (YYYY)%m: Month (01-12)%d: Day of month (01-31)%H: Hour (00-23)%M: Minute (00-59)%S: Second (00-60)%s: Unix epoch timestamp%J: Julian day numberAnd many more.
Example
// Get the current year and month: SELECT STRFTIME('%Y-%m', 'now');
select(STRFTIME("%Y-%m")).execute()
// Format a specific date from a string: SELECT STRFTIME('%d/%m/%Y', '2024-05-04');
select(STRFTIME("%d/%m/%Y", "2024-05-04")).execute() // Result: "04/05/2024"
// Format a date from a table column and apply modifiers
// SELECT STRFTIME('%Y-%m-%d %H:%M', LoginTime, '+5 hours') FROM Employees;
Employees
.select(STRFTIME("%Y-%m-%d %H:%M", Employees.loginTime.hours(5)))
.execute()Content copied to clipboard
Author
MOHAMMAD AZIM ANSARI
MOHAMMAD AZIM ANSARI
Return
A KQLiteColumn of type KQLiteDateTime representing the formatted date and time.
Parameters
format
A String representing the date/time format.
column
An optional KQLiteColumn containing a time string, which defaults to 'now' if omitted.