DateTime

ldbc.statement.functions.DateTime
See theDateTime companion object
trait DateTime

Provide functions that can be used to manipulate temporal values provided by MySQL.

Attributes

See also
Companion
object
Source
DateTime.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def ADDTIME[A <: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A], time: LocalTime): Column[A]

Function to perform addition on a specified date type column.

Function to perform addition on a specified date type column.

 TableQuery[DateTime].select(p => ADDTIME(p.time, LocalTime.of(1, 1, 1, 1)))
 // SELECT ADDTIME(time, '01:01:01.000000001') FROM date_time

Value parameters

column

The column to which the addition is to be performed.

time

The time to be added to the column.

Attributes

Source
DateTime.scala
def ADDTIME(dateTime: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime, time: LocalTime): Column[LocalTime]

Function to perform addition on a specified date type column.

Function to perform addition on a specified date type column.

 TableQuery[DateTime].select(p => ADDTIME(LocalTime.of(1, 1, 1, 1), LocalTime.of(1, 1, 1, 1)))
 // SELECT ADDTIME('01:01:01.000000001', '01:01:01.000000001') FROM date_time

Value parameters

dateTime

The date time to which the addition is to be performed.

time

The time to be added to the date time.

Attributes

Source
DateTime.scala
def CONVERT_TZ[A <: LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A], from: LocalTime, to: LocalTime): Column[A]

Function to convert a date-time value dt from the time zone specified by from_tz to the time zone specified by to_tz.

Function to convert a date-time value dt from the time zone specified by from_tz to the time zone specified by to_tz.

 TableQuery[DateTime].select(p => CONVERT_TZ(p.timestampe, LocalTime.of(0, 0), LocalTime.of(9, 0)))
 // SELECT CONVERT_TZ(timestampe, '+00:00', '+09:00') FROM date_time

Value parameters

column

The column to which the addition is to be performed.

from

The time zone from which the conversion is to be performed.

to

The time zone to which the conversion is to be performed.

Attributes

Source
DateTime.scala
def CONVERT_TZ(dateTime: LocalDateTime | OffsetDateTime | ZonedDateTime, from: LocalTime, to: LocalTime): Column[LocalDateTime]

Function to convert a date-time value dt from the time zone specified by from_tz to the time zone specified by to_tz.

Function to convert a date-time value dt from the time zone specified by from_tz to the time zone specified by to_tz.

 TableQuery[DateTime].select(p => CONVERT_TZ(LocalDateTime.of(2025, 1, 1), LocalTime.of(0, 0), LocalTime.of(9, 0)))
 // SELECT CONVERT_TZ('2025-01-01', '+00:00', '+09:00') FROM date_time

Value parameters

dateTime

The date time to which the addition is to be performed.

from

The time zone from which the conversion is to be performed.

to

The time zone to which the conversion is to be performed.

Attributes

Source
DateTime.scala
def CURDATE(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to return the current date as 'YYYY-MM-DD' format.

Function to return the current date as 'YYYY-MM-DD' format.

 TableQuery[DateTime].select(_ => CURDATE)
 // SELECT CURDATE() FROM date_time

Attributes

Source
DateTime.scala
def CURTIME(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to return the current time in 'hh:mm:ss' format.

Function to return the current time in 'hh:mm:ss' format.

 TableQuery[DateTime].select(_ => CURTIME)
 // SELECT CURTIME() FROM date_time

Attributes

Source
DateTime.scala
def DATE[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to extract the date portion of a date or date-time expression.

Function to extract the date portion of a date or date-time expression.

 TableQuery[DateTime].select(p => DATE(p.timestamp))
 // SELECT DATE(timestamp) FROM date_time

Value parameters

column

Date or date/time column from which to extract the date portion

Attributes

Source
DateTime.scala
def DATE(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime): Column[LocalDate]

Function to extract the date portion of a date or date-time expression.

Function to extract the date portion of a date or date-time expression.

 TableQuery[DateTime].select(_ => DATE(LocalDateTime.of(2025, 1, 1, 1, 1)))
 // SELECT DATE('2025-01-01T01:01') FROM date_time

Value parameters

date

The date or date-time expression from which the date portion is to be extracted.

Attributes

Source
DateTime.scala
def DATEDIFF[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime], B <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](from: Column[A], to: Column[B])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to calculate the value of the number of days from one date to another.

Function to calculate the value of the number of days from one date to another.

 TableQuery[DateTime].select(p => DATEDIFF(p.birthDate, p.deathDate))
 // SELECT DATEDIFF(birth_date, death_date) FROM date_time

Value parameters

from

The starting date.

to

The ending date.

Attributes

Source
DateTime.scala
def DATEDIFF[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](from: Column[A], to: LocalDate)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to calculate the value of the number of days from one date to another.

Function to calculate the value of the number of days from one date to another.

TableQuery[DateTime].select(p => DATEDIFF(p.birthDate, LocalDate.of(2021, 1, 1)))
// SELECT DATEDIFF(birth_date, '2021-01-01') FROM date_time

Value parameters

from

The starting date.

to

The ending date.

Attributes

Source
DateTime.scala
def DATEDIFF(from: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime, to: LocalDate)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to calculate the value of the number of days from one date to another.

Function to calculate the value of the number of days from one date to another.

TableQuery[DateTime].select(p => DATEDIFF(p.birthDate, LocalDate.of(2021, 1, 1)))
// SELECT DATEDIFF(birth_date, '2021-01-01') FROM date_time

Value parameters

from

The starting date.

to

The ending date.

Attributes

Source
DateTime.scala
def DATE_ADD[A <: LocalDate | Option[LocalDate]](column: Column[A], interval: Interval[Int]): Column[A]

Function to perform addition on a specified date type column.

Function to perform addition on a specified date type column.

 TableQuery[DateTime].select(p => DATE_ADD(p.birthDate, DateTime.Interval.YEAR(1)))
 // SELECT DATE_ADD(birth_date, INTERVAL 1 YEAR) FROM date_time

Value parameters

column

The column to which the addition is to be performed.

interval

The interval to be added to the column.

Attributes

Source
DateTime.scala
def DATE_ADD(date: LocalDate, interval: Interval[Int])(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to perform addition on a specified date type column.

Function to perform addition on a specified date type column.

 TableQuery[DateTime].select(p => DATE_ADD(LocalDate.now, DateTime.Interval.YEAR(1)))
 // SELECT DATE_ADD('2008-02-02', INTERVAL 1 YEAR) FROM date_time

Value parameters

date

The date to which the addition is to be performed.

interval

The interval to be added to the date.

Attributes

Source
DateTime.scala
def DATE_FORMAT[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A], format: String)(using Decoder[String], Encoder[String]): Column[String]

Function to format a date value according to the format string.

Function to format a date value according to the format string.

Value parameters

column

The column to be formatted.

format

The format string.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format

 TableQuery[DateTime].select(p => DATE_FORMAT(p.timestamp, "%Y-%m-%d"))
 // SELECT DATE_FORMAT(timestamp, '%Y-%m-%d') FROM date_time
Source
DateTime.scala
def DATE_FORMAT(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime, format: String): Column[String]

Function to format a date value according to the format string.

Function to format a date value according to the format string.

 TableQuery[DateTime].select(_ => DATE_FORMAT(LocalDate.of(2025, 1, 1), "%Y-%m-%d"))
 // SELECT DATE_FORMAT('2025-01-01', '%Y-%m-%d') FROM date_time

Value parameters

date

The date or date-time expression to be formatted.

format

The format string.

Attributes

Source
DateTime.scala
def DATE_SUB[A <: LocalDate | Option[LocalDate]](column: Column[A], interval: Interval[Int]): Column[A]

Function to perform subtraction on a given date type column.

Function to perform subtraction on a given date type column.

 TableQuery[DateTime].select(p => DATE_SUB(p.birthDate, DateTime.Interval.YEAR(1)))
 // SELECT DATE_SUB(birth_date, INTERVAL 1 YEAR) FROM date_time

Value parameters

column

The column to which the subtraction is to be performed.

interval

The interval to be subtraction to the column.

Attributes

Source
DateTime.scala
def DATE_SUB(date: LocalDate, interval: Interval[Int])(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to perform subtraction on a given date.

Function to perform subtraction on a given date.

 TableQuery[DateTime].select(p => DATE_SUB(LocalDate.now, DateTime.Interval.YEAR(1)))
 // SELECT DATE_SUB('2008-02-02', INTERVAL 1 YEAR) FROM date_time

Value parameters

date

The date to which the subtraction is to be performed.

interval

The interval to be subtraction to the date.

Attributes

Source
DateTime.scala
def DAYNAME[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[String], Encoder[String]): Column[String]

A function that returns the name of the day of the week corresponding to date. The language used for the names is controlled by the value of the lc_time_names system variable (Section 10.16, “Locale Support in MySQL Server”).

A function that returns the name of the day of the week corresponding to date. The language used for the names is controlled by the value of the lc_time_names system variable (Section 10.16, “Locale Support in MySQL Server”).

Value parameters

column

The date or date-time column from which to extract the day of the week.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/locale-support.html

 TableQuery[DateTime].select(p => DAYNAME(p.birthDate))
 // SELECT DAYNAME(birth_date) FROM date_time
Source
DateTime.scala
def DAYNAME(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[String], Encoder[String]): Column[String]

A function that returns the name of the day of the week corresponding to date. The language used for the names is controlled by the value of the lc_time_names system variable (Section 10.16, “Locale Support in MySQL Server”).

A function that returns the name of the day of the week corresponding to date. The language used for the names is controlled by the value of the lc_time_names system variable (Section 10.16, “Locale Support in MySQL Server”).

Value parameters

date

The date or date-time expression from which to extract the day of the week.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/locale-support.html

 TableQuery[DateTime].select(_ => DAYNAME(LocalDate.of(2021, 1, 1)))
 // SELECT DAYNAME('2021-01-01') FROM date_time
Source
DateTime.scala
def DAYOFMONTH[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

A function that returns the day of the month for date, in the range 1 to 31, or 0 for dates such as '0000-00-00' or '2008-00-00' that have a zero day part.

A function that returns the day of the month for date, in the range 1 to 31, or 0 for dates such as '0000-00-00' or '2008-00-00' that have a zero day part.

TableQuery[DateTime].select(p => DAYOFMONTH(p.birthDate))
// SELECT DAYOFMONTH(birth_date) FROM date_time

Value parameters

column

The date or date-time column from which to extract the day of the month.

Attributes

Source
DateTime.scala
def DAYOFMONTH(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

A function that returns the day of the month for date, in the range 1 to 31, or 0 for dates such as '0000-00-00' or '2008-00-00' that have a zero day part.

A function that returns the day of the month for date, in the range 1 to 31, or 0 for dates such as '0000-00-00' or '2008-00-00' that have a zero day part.

 TableQuery[DateTime].select(_ => DAYOFMONTH(LocalDate.of(2021, 1, 1)))
 // SELECT DAYOFMONTH('2021-01-01') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the day of the month.

Attributes

Source
DateTime.scala
def DAYOFWEEK[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

A function that returns the day of the week for date, in the range 1 to 7, where 1 represents Sunday. Day of the week index (1 = Sunday, 2 = Monday, ..., 7 = Saturday) for date.

A function that returns the day of the week for date, in the range 1 to 7, where 1 represents Sunday. Day of the week index (1 = Sunday, 2 = Monday, ..., 7 = Saturday) for date.

TableQuery[DateTime].select(p => DAYOFWEEK(p.birthDate))
// SELECT DAYOFWEEK(birth_date) FROM date_time

Value parameters

column

The date or date-time column from which to extract the day of the week.

Attributes

Source
DateTime.scala
def DAYOFWEEK(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

A function that returns the day of the week for date, in the range 1 to 7, where 1 represents Sunday. Day of the week index (1 = Sunday, 2 = Monday, ..., 7 = Saturday) for date.

A function that returns the day of the week for date, in the range 1 to 7, where 1 represents Sunday. Day of the week index (1 = Sunday, 2 = Monday, ..., 7 = Saturday) for date.

TableQuery[DateTime].select(_ => DAYOFWEEK(LocalDate.of(2021, 1, 1)))
// SELECT DAYOFWEEK('2021-01-01') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the day of the week.

Attributes

Source
DateTime.scala
def DAYOFYEAR[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

A function that returns the day of the year for date, in the range 1 to 366. The range of DAYOFYEAR() is 1 to 366 because MySQL supports leap year.

A function that returns the day of the year for date, in the range 1 to 366. The range of DAYOFYEAR() is 1 to 366 because MySQL supports leap year.

 TableQuery[DateTime].select(p => DAYOFYEAR(p.birthDate))
 // SELECT DAYOFYEAR(birth_date) FROM date_time

Value parameters

column

The date or date-time column from which to extract the day of the year.

Attributes

Source
DateTime.scala
def DAYOFYEAR(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

A function that returns the day of the year for date, in the range 1 to 366. The range of DAYOFYEAR() is 1 to 366 because MySQL supports leap year.

A function that returns the day of the year for date, in the range 1 to 366. The range of DAYOFYEAR() is 1 to 366 because MySQL supports leap year.

 TableQuery[DateTime].select(_ => DAYOFYEAR(LocalDate.of(2021, 1, 1)))
 // SELECT DAYOFYEAR('2021-01-01') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the day of the year.

Attributes

Source
DateTime.scala
def EXTRACT[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A], timeUnit: TimeUnit)(using Decoder[Int], Encoder[Int]): Column[Int]

A function that returns the time part of the expression expr as a time value.

A function that returns the time part of the expression expr as a time value.

 TableQuery[DateTime].select(p => EXTRACT(p.timestamp, DateTime.TimeUnit.HOUR))
 // SELECT EXTRACT(HOUR FROM timestamp) FROM date_time

Value parameters

column

The column from which to extract the time part.

timeUnit

The time unit to be extracted.

Attributes

Source
DateTime.scala
def EXTRACT(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime, timeUnit: TimeUnit)(using Decoder[Int], Encoder[Int]): Column[Int]

A function that returns the time part of the expression expr as a time value.

A function that returns the time part of the expression expr as a time value.

 TableQuery[DateTime].select(_ => EXTRACT(LocalDateTime.of(2021, 1, 1, 0, 0), DateTime.TimeUnit.HOUR))
 // SELECT EXTRACT(HOUR FROM '2021-01-01T00:00') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the time part.

timeUnit

The time unit to be extracted.

Attributes

Source
DateTime.scala
def FROM_DAYS[A <: Int | Long | Option[Int | Long]](column: Column[A])(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to convert a day value to a date.

Function to convert a day value to a date.

Use FROM_DAYS() carefully with older dates. It is not designed to be used with values prior to the advent of the Gregorian calendar (1582).

Value parameters

column

The column from which to extract the date.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/mysql-calendar.html

 TableQuery[DateTime].select(p => FROM_DAYS(p.birthDate))
 // SELECT FROM_DAYS(birth_date) FROM date_time
Source
DateTime.scala
def FROM_DAYS[A <: Int | Long | Option[Int | Long]](days: A)(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to convert a day value to a date.

Function to convert a day value to a date.

Use FROM_DAYS() carefully with older dates. It is not designed to be used with values prior to the advent of the Gregorian calendar (1582).

Value parameters

days

The number of days from which to extract the date.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/mysql-calendar.html

 TableQuery[DateTime].select(_ => FROM_DAYS(730669))
 // SELECT FROM_DAYS(730669) FROM date_time
Source
DateTime.scala
def FROM_UNIXTIME[A <: Int | Long | Option[Int | Long]](column: Column[A])(using Decoder[LocalDateTime], Encoder[LocalDateTime]): Column[LocalDateTime]

Function to generate a UTC date in YYYYY-MM-DD hh:mm:ss format from a number.

Function to generate a UTC date in YYYYY-MM-DD hh:mm:ss format from a number.

 TableQuery[DateTime].select(p => FROM_UNIXTIME(p.birthDate))
 // SELECT FROM_UNIXTIME(birth_date) FROM date_time

Value parameters

column

The column from which to extract the date.

Attributes

Source
DateTime.scala
def FROM_UNIXTIME(timestamp: Int | Long)(using Decoder[String], Encoder[String]): Column[String]

Function to generate a UTC date in YYYYY-MM-DD hh:mm:ss format from a number.

Function to generate a UTC date in YYYYY-MM-DD hh:mm:ss format from a number.

TableQuery[DateTime].select(_ => FROM_UNIXTIME(1612137600))
// SELECT FROM_UNIXTIME(1612137600) FROM date_time

Value parameters

timestamp

The number from which to extract the date.

Attributes

Source
DateTime.scala
def GET_FORMAT(dateType: DateType, formatType: FormatType)(using Decoder[String], Encoder[String]): Column[String]

Function that returns a format string that can be used with DATE_FORMAT() and STR_TO_DATE() functions.

Function that returns a format string that can be used with DATE_FORMAT() and STR_TO_DATE() functions.

 TableQuery[DateTime].select(_ => GET_FORMAT(DateTime.DateType.DATE, DateTime.FormatType.USA))
 // SELECT GET_FORMAT(DATE, 'USA') FROM date_time

Value parameters

dateType

The type of date/time format (DATE, TIME, DATETIME).

formatType

The format style (EUR, USA, JIS, ISO, INTERNAL).

Attributes

Source
DateTime.scala
def HOUR[A <: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function for extracting time-only values from date types. The range of returned values is from 0 to 23 for date-time values. However, since the range of TIME values is actually much larger, HOUR can return values greater than 23.

Function for extracting time-only values from date types. The range of returned values is from 0 to 23 for date-time values. However, since the range of TIME values is actually much larger, HOUR can return values greater than 23.

 TableQuery[DateTime].select(p => HOUR(p.birthDate))
 // SELECT HOUR(birth_date) FROM date_time

Value parameters

column

The column from which to extract the hour.

Attributes

Source
DateTime.scala
def HOUR(date: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function for extracting time-only values from date types. The range of returned values is from 0 to 23 for date-time values. However, since the range of TIME values is actually much larger, HOUR can return values greater than 23.

Function for extracting time-only values from date types. The range of returned values is from 0 to 23 for date-time values. However, since the range of TIME values is actually much larger, HOUR can return values greater than 23.

 TableQuery[DateTime].select(_ => HOUR(LocalTime.of(1, 1, 1, 1)))
 // SELECT HOUR('01:01:01.000000001') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the hour.

Attributes

Source
DateTime.scala
def LAST_DAY[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function that returns the value corresponding to the last day of the month from a date or date-time value.

Function that returns the value corresponding to the last day of the month from a date or date-time value.

 TableQuery[DateTime].select(p => LAST_DAY(p.birthDate))
 // SELECT LAST_DAY(birth_date) FROM date_time

Value parameters

column

The column from which to extract the last day of the month.

Attributes

Source
DateTime.scala
def LAST_DAY(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function that returns the value corresponding to the last day of the month from a date or date-time value.

Function that returns the value corresponding to the last day of the month from a date or date-time value.

 TableQuery[DateTime].select(_ => LAST_DAY(LocalDate.of(2021, 1, 1)))
 // SELECT LAST_DAY('2021-01-01') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the last day of the month.

Attributes

Source
DateTime.scala
def MAKEDATE[A <: Year | Option[Year]](column: Column[A], day: Int)(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to return a date calculated from a given year and annual total.

Function to return a date calculated from a given year and annual total.

 TableQuery[DateTime].select(p => MAKEDATE(p.birthDate, 1))
 // SELECT MAKEDATE(birth_date, 1) FROM date_time

Value parameters

column

The column from which to calculate the date.

day

The annual total from which to calculate the date. The annual total must be greater than 0.

Attributes

Source
DateTime.scala
def MAKEDATE(year: Int | Year, day: Int)(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to return a date calculated from a given year and annual total.

Function to return a date calculated from a given year and annual total.

 TableQuery[DateTime].select(p => MAKEDATE(2021, 1))
 // SELECT MAKEDATE(2021, 1) FROM date_time

Value parameters

day

The annual total from which to calculate the date. The annual total must be greater than 0.

year

The year from which to calculate the date.

Attributes

Source
DateTime.scala
def MAKETIME[A <: Int | Long | Option[Int | Long], B <: Int | Long | Option[Int | Long], C <: Int | Long | Option[Int | Long]](hour: Column[A], minute: Column[B], second: Column[C])(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to return a time value calculated from the given hour, minute, and second. The range of the hour is 0 to 23, the range of the minute is 0 to 59, and the range of the second is 0 to 59.

Function to return a time value calculated from the given hour, minute, and second. The range of the hour is 0 to 23, the range of the minute is 0 to 59, and the range of the second is 0 to 59.

 TableQuery[DateTime].select(p => MAKETIME(p.hour, p.minute, p.second))
 // SELECT MAKETIME(hour, minute, second) FROM date_time

Value parameters

hour

The hour from which to calculate the time.

minute

The minute from which to calculate the time.

second

The second from which to calculate the time.

Attributes

Source
DateTime.scala
def MAKETIME(hour: Int | Long, minute: Int | Long, second: Int | Long)(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to return a time value calculated from the given hour, minute, and second. The range of the hour is 0 to 23, the range of the minute is 0 to 59, and the range of the second is 0 to 59.

Function to return a time value calculated from the given hour, minute, and second. The range of the hour is 0 to 23, the range of the minute is 0 to 59, and the range of the second is 0 to 59.

 TableQuery[DateTime].select(_ => MAKETIME(1, 1, 1))
 // SELECT MAKETIME(1, 1, 1) FROM date_time

Value parameters

hour

The hour from which to calculate the time.

minute

The minute from which to calculate the time.

second

The second from which to calculate the time.

Attributes

Source
DateTime.scala
def MICROSECOND[A <: LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function that returns microseconds from a time or date-time expression as a number in the range 0 to 999999.

Function that returns microseconds from a time or date-time expression as a number in the range 0 to 999999.

 TableQuery[DateTime].select(p => MICROSECOND(p.birthDate))
 // SELECT MICROSECOND(birth_date) FROM date_time

Value parameters

column

The column from which to extract the microseconds.

Attributes

Source
DateTime.scala
def MICROSECOND(datetime: LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function that returns microseconds from a time or date-time expression as a number in the range 0 to 999999.

Function that returns microseconds from a time or date-time expression as a number in the range 0 to 999999.

 TableQuery[DateTime].select(_ => MICROSECOND(LocalDateTime.of(2021, 1, 1, 0, 0)))
 // SELECT MICROSECOND('2021-01-01 00:00') FROM date_time

Value parameters

datetime

The date or date-time expression from which to extract the microseconds.

Attributes

Source
DateTime.scala
def MINUTE[A <: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function that returns the minute part of a date or date-time expression. The range of the minute is 0 to 59.

Function that returns the minute part of a date or date-time expression. The range of the minute is 0 to 59.

 TableQuery[DateTime].select(p => MINUTE(p.birthDate))
 // SELECT MINUTE(birth_date) FROM date_time

Value parameters

column

The column from which to extract the minute.

Attributes

Source
DateTime.scala
def MINUTE(time: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function that returns the minute part of a date or date-time expression. The range of the minute is 0 to 59.

Function that returns the minute part of a date or date-time expression. The range of the minute is 0 to 59.

 TableQuery[DateTime].select(_ => MINUTE(LocalDateTime.of(2021, 1, 1, 0, 0)))
 // SELECT MINUTE('2021-01-01 00:00') FROM date_time

Value parameters

time

The date or date-time expression from which to extract the minute.

Attributes

Source
DateTime.scala
def MONTH[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function that returns the month part of a date or date-time expression. The range of the month is 1 to 12.

Function that returns the month part of a date or date-time expression. The range of the month is 1 to 12.

 TableQuery[DateTime].select(p => MONTH(p.birthDate))
 // SELECT MONTH(birth_date) FROM date_time

Value parameters

column

The column from which to extract the month.

Attributes

Source
DateTime.scala
def MONTH(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function that returns the month part of a date or date-time expression. The range of the month is 1 to 12.

Function that returns the month part of a date or date-time expression. The range of the month is 1 to 12.

 TableQuery[DateTime].select(_ => MONTH(LocalDateTime.of(2021, 1, 1, 0, 0)))
 // SELECT MONTH('2021-01-01 00:00') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the month.

Attributes

Source
DateTime.scala
def MONTHNAME[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[String], Encoder[String]): Column[String]

Function to return the full name of the month corresponding to a value of type Date. The language used for names is controlled by the value of the lc_time_names system variable (Section 10.16, “Locale Support in MySQL Server”).

Function to return the full name of the month corresponding to a value of type Date. The language used for names is controlled by the value of the lc_time_names system variable (Section 10.16, “Locale Support in MySQL Server”).

Value parameters

column

The date or date-time column from which to extract the month name.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/locale-support.html

 TableQuery[DateTime].select(p => MONTHNAME(p.birthDate))
 // SELECT MONTHNAME(birth_date) FROM date_time
Source
DateTime.scala
def MONTHNAME(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[String], Encoder[String]): Column[String]

Function to return the full name of the month corresponding to a value of type Date. The language used for names is controlled by the value of the lc_time_names system variable (Section 10.16, “Locale Support in MySQL Server”).

Function to return the full name of the month corresponding to a value of type Date. The language used for names is controlled by the value of the lc_time_names system variable (Section 10.16, “Locale Support in MySQL Server”).

Value parameters

date

The date or date-time expression from which to extract the month name.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/locale-support.html

 TableQuery[DateTime].select(_ => MONTHNAME(LocalDate.of(2021, 1, 1)))
 // SELECT MONTHNAME('2021-01-01') FROM date_time
Source
DateTime.scala
def NOW()(using Decoder[LocalDateTime], Encoder[LocalDateTime]): Column[LocalDateTime]

Function to return the current date and time in 'YYYY-MM-DD hh:mm:ss' format.

Function to return the current date and time in 'YYYY-MM-DD hh:mm:ss' format.

 TableQuery[DateTime].select(_ => NOW)
 // SELECT NOW() FROM date_time

Attributes

Source
DateTime.scala
def PERIOD_ADD(period: YearMonth, months: Int): Column[YearMonth]

Function to add the specified month to the yyyyMM value.

Function to add the specified month to the yyyyMM value.

Value parameters

months

The number of months to add.

period

The period in yyyyMM format.

Attributes

Source
DateTime.scala
def PERIOD_DIFF(period1: YearMonth, period2: YearMonth)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the number of months between periods.

Function to return the number of months between periods.

 TableQuery[DateTime].select(_ => PERIOD_DIFF(YearMonth.of(2008, 2), YearMonth.of(2007, 3)))
 // SELECT PERIOD_DIFF(200802, 200703) FROM date_time

Value parameters

period1

First period in YYYYMM format.

period2

Second period in YYYYMM format.

Attributes

Source
DateTime.scala
def QUARTER[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the quarter corresponding to date in the range 1 to 4.

Function to return the quarter corresponding to date in the range 1 to 4.

 TableQuery[DateTime].select(p => QUARTER(p.birthDate))
 // SELECT QUARTER(birth_date) FROM date_time

Value parameters

column

The date or date-time column from which to extract the quarter.

Attributes

Source
DateTime.scala
def QUARTER(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the quarter corresponding to date in the range 1 to 4.

Function to return the quarter corresponding to date in the range 1 to 4.

 TableQuery[DateTime].select(_ => QUARTER(LocalDate.of(2021, 1, 1)))
 // SELECT QUARTER('2021-01-01') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the quarter.

Attributes

Source
DateTime.scala
def SECOND[A <: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the second part of a date or date-time expression.

Function to return the second part of a date or date-time expression.

 TableQuery[DateTime].select(p => SECOND(p.birthDate))
 // SELECT SECOND(birth_date) FROM date_time

Value parameters

column

The column from which to extract the second.

Attributes

Source
DateTime.scala
def SECOND(time: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the second part of a date or date-time expression.

Function to return the second part of a date or date-time expression.

 TableQuery[DateTime].select(_ => SECOND(LocalDateTime.of(2021, 1, 1, 0, 0)))
 // SELECT SECOND('2021-01-01 00:00') FROM date_time

Value parameters

time

The date or date-time expression from which to extract the second.

Attributes

Source
DateTime.scala
def SEC_TO_TIME[A <: Long | Int | Option[Long | Int]](column: Column[A]): Column[LocalTime]

Function to convert TIME values to hh:mm:ss format.

Function to convert TIME values to hh:mm:ss format.

 TableQuery[DateTime].select(p => SEC_TO_TIME(p.seconds))
 // SELECT SEC_TO_TIME(seconds) FROM date_time

Value parameters

column

The column to be converted.

Attributes

Source
DateTime.scala
def SEC_TO_TIME(seconds: Long): Column[LocalTime]

Function to convert TIME values to hh:mm:ss format.

Function to convert TIME values to hh:mm:ss format.

 TableQuery[DateTime].select(_ => SEC_TO_TIME(3600))
 // SELECT SEC_TO_TIME(3600) FROM date_time

Value parameters

seconds

The number of seconds to be converted.

Attributes

Source
DateTime.scala
def STR_TO_DATE[A <: String | Option[String]](column: Column[A], format: String)(using Decoder[Option[LocalDateTime]], Encoder[Option[LocalDateTime]]): Column[Option[LocalDateTime]]

Function to convert a string to a date according to a format string.

Function to convert a string to a date according to a format string.

 TableQuery[DateTime].select(p => STR_TO_DATE(p.dateString, "%d,%m,%Y"))
 // SELECT STR_TO_DATE(date_string, '%d,%m,%Y') FROM date_time

Value parameters

column

The string column to be converted to a date.

format

The format string specifying how to parse the input string.

Attributes

Source
DateTime.scala
def STR_TO_DATE(str: String, format: String)(using Decoder[Option[LocalDateTime]], Encoder[Option[LocalDateTime]]): Column[Option[LocalDateTime]]

Function to convert a string to a date according to a format string.

Function to convert a string to a date according to a format string.

 TableQuery[DateTime].select(_ => STR_TO_DATE("01,5,2013", "%d,%m,%Y"))
 // SELECT STR_TO_DATE('01,5,2013', '%d,%m,%Y') FROM date_time

Value parameters

format

The format string specifying how to parse the input string.

str

The input string to be converted to a date.

Attributes

Source
DateTime.scala
def SUBTIME[A <: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime], B <: LocalTime | Option[LocalTime]](time: Column[A], interval: Column[B])(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to calculate the difference time from a date/time or time type value.

Function to calculate the difference time from a date/time or time type value.

 TableQuery[DateTime].select(p => SUBTIME(p.start, p.end))
 // SELECT SUBTIME(start, end) FROM date_time

Value parameters

interval

The end time.

time

The start time.

Attributes

Source
DateTime.scala
def SUBTIME(time: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime, interval: LocalTime)(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to calculate the difference time from a date/time or time type value.

Function to calculate the difference time from a date/time or time type value.

 TableQuery[DateTime].select(_ => SUBTIME(LocalDateTime.of(2021, 1, 1, 0, 0), LocalDateTime.of(2021, 1, 1, 0, 0)))
 // SELECT SUBTIME('2021-01-01 00:00', '2021-01-01 00:00') FROM date_time

Value parameters

interval

The end time.

time

The start time.

Attributes

Source
DateTime.scala
def SYSDATE()(using Decoder[LocalDateTime], Encoder[LocalDateTime]): Column[LocalDateTime]

Function to return the current date and time in 'YYYY-MM-DD hh:mm:ss' format.

Function to return the current date and time in 'YYYY-MM-DD hh:mm:ss' format.

 TableQuery[DateTime].select(_ => SYSDATE)
 // SELECT SYSDATE() FROM date_time

Attributes

Source
DateTime.scala
def TIME[A <: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to extract only the time portion from a time or date-time expression value.

Function to extract only the time portion from a time or date-time expression value.

 TableQuery[DateTime].select(p => TIME(p.birthDate))
 // SELECT TIME(birth_date) FROM date_time

Value parameters

column

The column from which to extract the time.

Attributes

Source
DateTime.scala
def TIME(time: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to extract only the time portion from a time or date-time expression value.

Function to extract only the time portion from a time or date-time expression value.

 TableQuery[DateTime].select(_ => TIME(LocalDateTime.of(2021, 1, 1, 0, 0)))
 // SELECT TIME('2021-01-01 00:00') FROM date_time

Value parameters

time

The time or date-time expression from which to extract the time.

Attributes

Source
DateTime.scala
def TIMEDIFF[A <: LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDateTime | OffsetDateTime | ZonedDateTime]](start: Column[A], end: Column[A])(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

A function that calculates the difference of the time portion from a date/time type value and returns the result as a time type.

A function that calculates the difference of the time portion from a date/time type value and returns the result as a time type.

 TableQuery[DateTime].select(p => TIMEDIFF(p.start, p.end))
 // SELECT TIMEDIFF(start, end) FROM date_time

Value parameters

end

The end time.

start

The start time.

Attributes

Source
DateTime.scala
def TIMEDIFF[A <: LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDateTime | OffsetDateTime | ZonedDateTime]](start: Column[A], end: LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

A function that calculates the difference of the time portion from a date/time type value and returns the result as a time type.

A function that calculates the difference of the time portion from a date/time type value and returns the result as a time type.

TableQuery[DateTime].select(p => TIMEDIFF(p.start, LocalDateTime.of(2021, 1, 1, 0, 0)))
// SELECT TIMEDIFF(start, '2021-01-01 00:00') FROM date_time

Value parameters

end

The end time.

start

The start time.

Attributes

Source
DateTime.scala
def TIMEDIFF[A <: LocalDateTime | OffsetDateTime | ZonedDateTime](start: A, end: A)(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

A function that calculates the difference of the time portion from a date/time type value and returns the result as a time type.

A function that calculates the difference of the time portion from a date/time type value and returns the result as a time type.

 TableQuery[DateTime].select(_ => TIMEDIFF(LocalDateTime.of(2021, 1, 1, 0, 0), LocalDateTime.of(2021, 1, 1, 0, 0)))
 // SELECT TIMEDIFF('2021-01-01 00:00', '2021-01-01 00:00') FROM date_time

Value parameters

end

The end time.

start

The start time.

Attributes

Source
DateTime.scala
def TIMESTAMP[A <: LocalDate | Option[LocalDate]](column: Column[A])(using Decoder[Option[LocalDateTime]], Encoder[Option[LocalDateTime]]): Column[Option[LocalDateTime]]

Function to return a date or date-time format value as a date-time value.

Function to return a date or date-time format value as a date-time value.

 TableQuery[DateTime].select(p => TIMESTAMP(p.birthDate))
 // SELECT TIMESTAMP(birth_date) FROM date_time

Value parameters

column

The column from which to extract the date-time value.

Attributes

Source
DateTime.scala
def TIMESTAMP[A <: LocalDate](date: A)(using Decoder[Option[LocalDateTime]], Encoder[Option[LocalDateTime]]): Column[Option[LocalDateTime]]

Function to return a date or date-time format value as a date-time value.

Function to return a date or date-time format value as a date-time value.

 TableQuery[DateTime].select(_ => TIMESTAMP(LocalDate.of(2021, 1, 1)))
 // SELECT TIMESTAMP('2021-01-01') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the date-time value.

Attributes

Source
DateTime.scala
def TIMESTAMP[A <: LocalDateTime | Option[LocalDateTime], B <: LocalTime | Option[LocalTime]](column1: Column[A], column2: Column[B])(using Decoder[Option[LocalDateTime]], Encoder[Option[LocalDateTime]]): Column[Option[LocalDateTime]]

Function that adds the value of a time expression to the value of a date or date-time expression and returns the result as a date-time value.

Function that adds the value of a time expression to the value of a date or date-time expression and returns the result as a date-time value.

 TableQuery[DateTime].select(p => TIMESTAMP(p.birthDate, p.birthTime))
 // SELECT TIMESTAMP(birth_date, birth_time) FROM date_time

Value parameters

column1

The date or date-time expression.

column2

The time expression.

Attributes

Source
DateTime.scala
def TIMESTAMPADD[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](unit: TimeUnit, interval: Int, column: Column[A]): Column[A]

Function to add an interval to a date or datetime expression.

Function to add an interval to a date or datetime expression.

 TableQuery[DateTime].select(p => TIMESTAMPADD(DateTime.TimeUnit.MINUTE, 1, p.timestamp))
 // SELECT TIMESTAMPADD(MINUTE, 1, timestamp) FROM date_time

Value parameters

column

The date or datetime column to which the interval will be added.

interval

The number of units to add.

unit

The time unit specifying how to add the interval.

Attributes

Source
DateTime.scala
def TIMESTAMPADD(unit: TimeUnit, interval: Int, datetime: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[LocalDateTime], Encoder[LocalDateTime]): Column[LocalDateTime]

Function to add an interval to a date or datetime expression.

Function to add an interval to a date or datetime expression.

 TableQuery[DateTime].select(_ => TIMESTAMPADD(DateTime.TimeUnit.MINUTE, 1, LocalDateTime.of(2003, 1, 2, 0, 0)))
 // SELECT TIMESTAMPADD(MINUTE, 1, '2003-01-02 00:00:00') FROM date_time

Value parameters

datetime

The date or datetime expression to which the interval will be added.

interval

The number of units to add.

unit

The time unit specifying how to add the interval.

Attributes

Source
DateTime.scala
def TIMESTAMPDIFF[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime], B <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](unit: TimeUnit, from: Column[A], to: Column[B])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to calculate the difference between two date or datetime expressions.

Function to calculate the difference between two date or datetime expressions.

 TableQuery[DateTime].select(p => TIMESTAMPDIFF(DateTime.TimeUnit.MONTH, p.startDate, p.endDate))
 // SELECT TIMESTAMPDIFF(MONTH, start_date, end_date) FROM date_time

Value parameters

from

The starting date or datetime expression.

to

The ending date or datetime expression.

unit

The time unit for the difference calculation.

Attributes

Source
DateTime.scala
def TIMESTAMPDIFF[B <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](unit: TimeUnit, from: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime, to: Column[B])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to calculate the difference between two date or datetime expressions.

Function to calculate the difference between two date or datetime expressions.

 TableQuery[DateTime].select(p => TIMESTAMPDIFF(DateTime.TimeUnit.MONTH, LocalDate.of(2003, 2, 1), p.endDate))
 // SELECT TIMESTAMPDIFF(MONTH, '2003-02-01', end_date) FROM date_time

Value parameters

from

The starting date or datetime expression.

to

The ending date or datetime column.

unit

The time unit for the difference calculation.

Attributes

Source
DateTime.scala
def TIMESTAMPDIFF(unit: TimeUnit, from: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime, to: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to calculate the difference between two date or datetime expressions.

Function to calculate the difference between two date or datetime expressions.

 TableQuery[DateTime].select(_ => TIMESTAMPDIFF(DateTime.TimeUnit.MONTH, LocalDate.of(2003, 2, 1), LocalDate.of(2003, 5, 1)))
 // SELECT TIMESTAMPDIFF(MONTH, '2003-02-01', '2003-05-01') FROM date_time

Value parameters

from

The starting date or datetime expression.

to

The ending date or datetime expression.

unit

The time unit for the difference calculation.

Attributes

Source
DateTime.scala
def TIME_FORMAT[A <: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A], format: String)(using Decoder[String], Encoder[String]): Column[String]

Function to format a time value according to the format string.

Function to format a time value according to the format string.

Value parameters

column

The time column to be formatted.

format

The format string.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_time-format

 TableQuery[DateTime].select(p => TIME_FORMAT(p.time, "%H:%i:%s"))
 // SELECT TIME_FORMAT(time, '%H:%i:%s') FROM date_time
Source
DateTime.scala
def TIME_FORMAT(time: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime, format: String)(using Decoder[String], Encoder[String]): Column[String]

Function to format a time value according to the format string.

Function to format a time value according to the format string.

 TableQuery[DateTime].select(_ => TIME_FORMAT(LocalTime.of(10, 15, 30), "%H:%i:%s"))
 // SELECT TIME_FORMAT('10:15:30', '%H:%i:%s') FROM date_time

Value parameters

format

The format string.

time

The time or date-time expression to be formatted.

Attributes

Source
DateTime.scala
def TIME_TO_SEC[A <: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Long], Encoder[Long]): Column[Long]

Function to convert the time portion from a date type value to seconds.

Function to convert the time portion from a date type value to seconds.

 TableQuery[DateTime].select(p => TIME_TO_SEC(p.birthDate))
 // SELECT TIME_TO_SEC(birth_date) FROM date_time

Value parameters

column

The column from which to extract the time.

Attributes

Source
DateTime.scala
def TIME_TO_SEC(time: LocalTime | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Long], Encoder[Long]): Column[Long]

Function to convert the time portion from a date type value to seconds.

Function to convert the time portion from a date type value to seconds.

 TableQuery[DateTime].select(_ => TIME_TO_SEC(LocalDateTime.of(2021, 1, 1, 0, 0)))
 // SELECT TIME_TO_SEC('2021-01-01 00:00') FROM date_time

Value parameters

time

The time or date-time expression from which to extract the time.

Attributes

Source
DateTime.scala
def TO_DAYS[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Option[Long]], Encoder[Option[Long]]): Column[Option[Long]]

Function to return the number of days since year 0.

Function to return the number of days since year 0.

Use TO_DAYS() carefully with older dates. It is not designed to be used with values prior to the advent of the Gregorian calendar (1582).

Value parameters

column

The date column to convert to days.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/mysql-calendar.html

 TableQuery[DateTime].select(p => TO_DAYS(p.birthDate))
 // SELECT TO_DAYS(birth_date) FROM date_time
Source
DateTime.scala
def TO_DAYS(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Option[Long]], Encoder[Option[Long]]): Column[Option[Long]]

Function to return the number of days since year 0.

Function to return the number of days since year 0.

Use TO_DAYS() carefully with older dates. It is not designed to be used with values prior to the advent of the Gregorian calendar (1582).

Value parameters

date

The date or date-time expression to convert to days.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/mysql-calendar.html

 TableQuery[DateTime].select(_ => TO_DAYS(LocalDate.of(2007, 10, 7)))
 // SELECT TO_DAYS('2007-10-07') FROM date_time
Source
DateTime.scala
def TO_SECONDS[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Option[Long]], Encoder[Option[Long]]): Column[Option[Long]]

Function to return the number of seconds since year 0.

Function to return the number of seconds since year 0.

Use TO_SECONDS() carefully with older dates. It is not designed to be used with values prior to the advent of the Gregorian calendar (1582).

Value parameters

column

The date or datetime column to convert to seconds.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/mysql-calendar.html

 TableQuery[DateTime].select(p => TO_SECONDS(p.timestamp))
 // SELECT TO_SECONDS(timestamp) FROM date_time
Source
DateTime.scala
def TO_SECONDS(datetime: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Option[Long]], Encoder[Option[Long]]): Column[Option[Long]]

Function to return the number of seconds since year 0.

Function to return the number of seconds since year 0.

Use TO_SECONDS() carefully with older dates. It is not designed to be used with values prior to the advent of the Gregorian calendar (1582).

Value parameters

datetime

The date or date-time expression to convert to seconds.

Attributes

See also

https://dev.mysql.com/doc/refman/8.0/en/mysql-calendar.html

 TableQuery[DateTime].select(_ => TO_SECONDS(LocalDateTime.of(2009, 11, 29, 13, 43, 32)))
 // SELECT TO_SECONDS('2009-11-29 13:43:32') FROM date_time
Source
DateTime.scala

Function to return a Unix timestamp. Without arguments, returns the current Unix timestamp (seconds since '1970-01-01 00:00:00' UTC).

Function to return a Unix timestamp. Without arguments, returns the current Unix timestamp (seconds since '1970-01-01 00:00:00' UTC).

 TableQuery[DateTime].select(_ => UNIX_TIMESTAMP())
 // SELECT UNIX_TIMESTAMP() FROM date_time

Attributes

Source
DateTime.scala
def UNIX_TIMESTAMP[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Option[Long]], Encoder[Option[Long]]): Column[Option[Long]]

Function to return a Unix timestamp for a given date. Returns seconds since '1970-01-01 00:00:00' UTC for the given date.

Function to return a Unix timestamp for a given date. Returns seconds since '1970-01-01 00:00:00' UTC for the given date.

 TableQuery[DateTime].select(p => UNIX_TIMESTAMP(p.timestamp))
 // SELECT UNIX_TIMESTAMP(timestamp) FROM date_time

Value parameters

column

The date or datetime column to convert to Unix timestamp.

Attributes

Source
DateTime.scala
def UNIX_TIMESTAMP(datetime: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Long], Encoder[Long]): Column[Long]

Function to return a Unix timestamp for a given date. Returns seconds since '1970-01-01 00:00:00' UTC for the given date.

Function to return a Unix timestamp for a given date. Returns seconds since '1970-01-01 00:00:00' UTC for the given date.

 TableQuery[DateTime].select(_ => UNIX_TIMESTAMP(LocalDateTime.of(2015, 11, 13, 10, 20, 19)))
 // SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19') FROM date_time

Value parameters

datetime

The date or date-time expression to convert to Unix timestamp.

Attributes

Source
DateTime.scala
def UTC_DATE()(using Decoder[LocalDate], Encoder[LocalDate]): Column[LocalDate]

Function to return the current UTC date in 'YYYY-MM-DD' format.

Function to return the current UTC date in 'YYYY-MM-DD' format.

 TableQuery[DateTime].select(_ => UTC_DATE())
 // SELECT UTC_DATE() FROM date_time

Attributes

Source
DateTime.scala
def UTC_TIME()(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to return the current UTC time in 'HH:MM:SS' format.

Function to return the current UTC time in 'HH:MM:SS' format.

 TableQuery[DateTime].select(_ => UTC_TIME())
 // SELECT UTC_TIME() FROM date_time

Attributes

Source
DateTime.scala
def UTC_TIME(fsp: Int)(using Decoder[LocalTime], Encoder[LocalTime]): Column[LocalTime]

Function to return the current UTC time with fractional seconds precision.

Function to return the current UTC time with fractional seconds precision.

 TableQuery[DateTime].select(_ => UTC_TIME(6))
 // SELECT UTC_TIME(6) FROM date_time

Value parameters

fsp

The fractional seconds precision (0-6).

Attributes

Source
DateTime.scala
def UTC_TIMESTAMP()(using Decoder[LocalDateTime], Encoder[LocalDateTime]): Column[LocalDateTime]

Function to return the current UTC date and time in 'YYYY-MM-DD HH:MM:SS' format.

Function to return the current UTC date and time in 'YYYY-MM-DD HH:MM:SS' format.

 TableQuery[DateTime].select(_ => UTC_TIMESTAMP())
 // SELECT UTC_TIMESTAMP() FROM date_time

Attributes

Source
DateTime.scala
def UTC_TIMESTAMP(fsp: Int)(using Decoder[LocalDateTime], Encoder[LocalDateTime]): Column[LocalDateTime]

Function to return the current UTC date and time with fractional seconds precision.

Function to return the current UTC date and time with fractional seconds precision.

 TableQuery[DateTime].select(_ => UTC_TIMESTAMP(6))
 // SELECT UTC_TIMESTAMP(6) FROM date_time

Value parameters

fsp

The fractional seconds precision (0-6).

Attributes

Source
DateTime.scala
def WEEK[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the week number for a date.

Function to return the week number for a date.

 TableQuery[DateTime].select(p => WEEK(p.birthDate))
 // SELECT WEEK(birth_date) FROM date_time

Value parameters

column

The date or date-time column from which to extract the week number.

Attributes

Source
DateTime.scala
def WEEK[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A], mode: Int)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the week number for a date with mode specification.

Function to return the week number for a date with mode specification.

 TableQuery[DateTime].select(p => WEEK(p.birthDate, 0))
 // SELECT WEEK(birth_date, 0) FROM date_time

Value parameters

column

The date or date-time column from which to extract the week number.

mode

The mode parameter for week calculation (0-7).

Attributes

Source
DateTime.scala
def WEEK(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the week number for a date.

Function to return the week number for a date.

 TableQuery[DateTime].select(_ => WEEK(LocalDate.of(2008, 2, 20)))
 // SELECT WEEK('2008-02-20') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the week number.

Attributes

Source
DateTime.scala
def WEEK(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime, mode: Int)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the week number for a date with mode specification.

Function to return the week number for a date with mode specification.

 TableQuery[DateTime].select(_ => WEEK(LocalDate.of(2008, 2, 20), 1))
 // SELECT WEEK('2008-02-20', 1) FROM date_time

Value parameters

date

The date or date-time expression from which to extract the week number.

mode

The mode parameter for week calculation (0-7).

Attributes

Source
DateTime.scala
def WEEKDAY[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the weekday index for a date. 0 = Monday, 1 = Tuesday, ... 6 = Sunday

Function to return the weekday index for a date. 0 = Monday, 1 = Tuesday, ... 6 = Sunday

 TableQuery[DateTime].select(p => WEEKDAY(p.birthDate))
 // SELECT WEEKDAY(birth_date) FROM date_time

Value parameters

column

The date or date-time column from which to extract the weekday index.

Attributes

Source
DateTime.scala
def WEEKDAY(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the weekday index for a date. 0 = Monday, 1 = Tuesday, ... 6 = Sunday

Function to return the weekday index for a date. 0 = Monday, 1 = Tuesday, ... 6 = Sunday

 TableQuery[DateTime].select(_ => WEEKDAY(LocalDate.of(2008, 2, 3)))
 // SELECT WEEKDAY('2008-02-03') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the weekday index.

Attributes

Source
DateTime.scala
def WEEKOFYEAR[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the calendar week of the date as a number in the range from 1 to 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).

Function to return the calendar week of the date as a number in the range from 1 to 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).

 TableQuery[DateTime].select(p => WEEKOFYEAR(p.birthDate))
 // SELECT WEEKOFYEAR(birth_date) FROM date_time

Value parameters

column

The date or date-time column from which to extract the week of year.

Attributes

Source
DateTime.scala
def WEEKOFYEAR(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return the calendar week of the date as a number in the range from 1 to 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).

Function to return the calendar week of the date as a number in the range from 1 to 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).

 TableQuery[DateTime].select(_ => WEEKOFYEAR(LocalDate.of(2008, 2, 20)))
 // SELECT WEEKOFYEAR('2008-02-20') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the week of year.

Attributes

Source
DateTime.scala
def YEARWEEK[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A])(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return year and week for a date. The year in the result may be different from the year in the date argument for the first and the last week of the year.

Function to return year and week for a date. The year in the result may be different from the year in the date argument for the first and the last week of the year.

 TableQuery[DateTime].select(p => YEARWEEK(p.birthDate))
 // SELECT YEARWEEK(birth_date) FROM date_time

Value parameters

column

The date or date-time column from which to extract the year and week.

Attributes

Source
DateTime.scala
def YEARWEEK[A <: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime | Option[LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime]](column: Column[A], mode: Int)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return year and week for a date with mode specification.

Function to return year and week for a date with mode specification.

 TableQuery[DateTime].select(p => YEARWEEK(p.birthDate, 0))
 // SELECT YEARWEEK(birth_date, 0) FROM date_time

Value parameters

column

The date or date-time column from which to extract the year and week.

mode

The mode parameter for week calculation (0-7).

Attributes

Source
DateTime.scala
def YEARWEEK(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return year and week for a date. The year in the result may be different from the year in the date argument for the first and the last week of the year.

Function to return year and week for a date. The year in the result may be different from the year in the date argument for the first and the last week of the year.

 TableQuery[DateTime].select(_ => YEARWEEK(LocalDate.of(1987, 1, 1)))
 // SELECT YEARWEEK('1987-01-01') FROM date_time

Value parameters

date

The date or date-time expression from which to extract the year and week.

Attributes

Source
DateTime.scala
def YEARWEEK(date: LocalDate | LocalDateTime | OffsetDateTime | ZonedDateTime, mode: Int)(using Decoder[Int], Encoder[Int]): Column[Int]

Function to return year and week for a date with mode specification.

Function to return year and week for a date with mode specification.

 TableQuery[DateTime].select(_ => YEARWEEK(LocalDate.of(1987, 1, 1), 0))
 // SELECT YEARWEEK('1987-01-01', 0) FROM date_time

Value parameters

date

The date or date-time expression from which to extract the year and week.

mode

The mode parameter for week calculation (0-7).

Attributes

Source
DateTime.scala