Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: "DAYNAME()"
doc_type: reference
mysql_compat: full
differs_from_mysql: []
mo_only: false
since: v3.0.15
last_updated: 2026-07-06
llms_summary: "Returns the weekday name for a DATE, DATETIME, or TIMESTAMP value, such as 'Monday' or 'Saturday'."
---
# DAYNAME()

> Returns the name of the weekday for a given date. The returned name uses the current locale's weekday names (e.g., `'Monday'`, `'Saturday'`). Accepts `DATE`, `DATETIME`, and `TIMESTAMP` types. Returns NULL if the argument is NULL.

## Function Description

The `DAYNAME()` function returns the full English weekday name for a date value. It is equivalent to calling `DATE_FORMAT(date, '%W')`.

## Syntax

```
> DAYNAME(date)
```

## Arguments

| Arguments | Description |
| ---- | ---- |
| date | Required. A value of type `DATE`, `DATETIME`, or `TIMESTAMP`. Returns NULL if NULL. |

## Examples

```sql
DROP DATABASE IF EXISTS dayname_demo;
CREATE DATABASE dayname_demo;
USE dayname_demo;

SELECT DAYNAME('2007-02-03') AS saturday;
SELECT DAYNAME('2007-02-05') AS monday;
SELECT DAYNAME('2007-02-03 12:30:45') AS dt_saturday;
SELECT DAYNAME(NULL) AS null_result;

CREATE TABLE t1(d DATE, dt DATETIME);
INSERT INTO t1 VALUES ('2007-02-03', '2007-02-03 12:00:00'), ('2007-02-04', '2007-02-04 12:00:00');
SELECT DAYNAME(d) AS day_from_date, DAYNAME(dt) AS day_from_datetime FROM t1;
DROP TABLE t1;

CREATE TABLE t2(d DATE);
INSERT INTO t2 VALUES ('2007-02-03'), ('2007-02-04'), ('2007-02-05');
SELECT * FROM t2 WHERE DAYNAME(d) = 'Saturday';
DROP TABLE t2;

DROP DATABASE dayname_demo;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: "MAKETIME()"
doc_type: reference
mysql_compat: full
differs_from_mysql: []
mo_only: false
since: v3.0.15
last_updated: 2026-07-06
llms_summary: "Returns a TIME value constructed from the given hour, minute, and second arguments, up to a maximum of 838:59:59."
---
# MAKETIME()

> Returns a `TIME` value constructed from the given `hour`, `minute`, and `second` arguments. The valid range for hours is 0–838. If any argument is out of range or NULL, returns NULL. Floating-point inputs are truncated to integers.

## Function Description

The `MAKETIME()` function constructs a `TIME` value from three integer arguments. MySQL's `TIME` type supports hours beyond 24 (up to 838), useful for representing time intervals or offsets.

## Syntax

```
> MAKETIME(hour, minute, second)
```

## Arguments

| Arguments | Description |
| ---- | ---- |
| hour | Required. Integer 0–838. Negative values or values > 838 return NULL. |
| minute | Required. Integer 0–59. Values outside this range return NULL. |
| second | Required. Integer 0–59. Values outside this range return NULL. |

## Examples

```sql
DROP DATABASE IF EXISTS maketime_demo;
CREATE DATABASE maketime_demo;
USE maketime_demo;

SELECT MAKETIME(12, 15, 30) AS result1;
SELECT MAKETIME(0, 0, 0) AS zero_time;
SELECT MAKETIME(23, 59, 59) AS max_time;
SELECT MAKETIME(838, 59, 59) AS max_hours;
SELECT MAKETIME(100, 0, 0) AS interval_time;

-- Out-of-range or invalid arguments return NULL.
SELECT MAKETIME(-1, 15, 30) AS null_hour_oob;
SELECT MAKETIME(12, 60, 30) AS null_minute_oob;
SELECT MAKETIME(12, 15, 60) AS null_second_oob;

SELECT MAKETIME(NULL, 15, 30) AS null_hour;
SELECT MAKETIME(12, NULL, 30) AS null_minute;

CREATE TABLE t1(h INT, m INT, s INT);
INSERT INTO t1 VALUES (12, 15, 30), (0, 0, 0), (23, 59, 59);
SELECT MAKETIME(h, m, s) AS time_value FROM t1;
DROP TABLE t1;

DROP DATABASE maketime_demo;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "MONTHNAME()"
doc_type: reference
mysql_compat: full
differs_from_mysql: []
mo_only: false
since: v3.0.15
last_updated: 2026-07-06
llms_summary: "Returns the full month name for a date value, such as 'January' or 'December', or NULL if the argument is NULL."
---
# MONTHNAME()

> Returns the full name of the month for a given date (e.g., `'January'`, `'December'`). Accepts `DATE`, `DATETIME`, and `TIMESTAMP` types. Returns NULL if the argument is NULL.

## Function Description

The `MONTHNAME()` function returns the full English month name for a date value. It is equivalent to calling `DATE_FORMAT(date, '%M')`.

## Syntax

```
> MONTHNAME(date)
```

## Arguments

| Arguments | Description |
| ---- | ---- |
| date | Required. A value of type `DATE`, `DATETIME`, or `TIMESTAMP`. Returns NULL if NULL. |

## Examples

```sql
DROP DATABASE IF EXISTS monthname_demo;
CREATE DATABASE monthname_demo;
USE monthname_demo;

SELECT MONTHNAME('2007-02-03') AS february;
SELECT MONTHNAME('2007-12-25') AS december;
SELECT MONTHNAME('2007-07-04 12:30:45') AS dt_july;
SELECT MONTHNAME(NULL) AS null_result;

CREATE TABLE t1(d DATE);
INSERT INTO t1 VALUES ('2007-01-15'), ('2007-06-20'), ('2007-12-31');
SELECT d, MONTHNAME(d) AS month_name FROM t1;
DROP TABLE t1;

DROP DATABASE monthname_demo;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "QUARTER()"
doc_type: reference
mysql_compat: full
differs_from_mysql: []
mo_only: false
since: v3.0.15
last_updated: 2026-07-06
llms_summary: "Returns the quarter of the year for a given date as an integer from 1 to 4, or NULL if the argument is NULL."
---
# QUARTER()

> Returns the quarter of the year for a given date as an integer value in the range 1–4. January–March returns 1, April–June returns 2, July–September returns 3, and October–December returns 4. Returns NULL if the argument is NULL.

## Function Description

The `QUARTER()` function extracts the quarter number from a date. It is useful for grouping or filtering data by fiscal or calendar quarters.

## Syntax

```
> QUARTER(date)
```

## Arguments

| Arguments | Description |
| ---- | ---- |
| date | Required. A value of type `DATE`, `DATETIME`, or `TIMESTAMP`. Returns NULL if NULL. |

## Examples

```sql
DROP DATABASE IF EXISTS quarter_demo;
CREATE DATABASE quarter_demo;
USE quarter_demo;

SELECT QUARTER('2007-01-15') AS q1;
SELECT QUARTER('2007-04-20') AS q2;
SELECT QUARTER('2007-08-05') AS q3;
SELECT QUARTER('2007-11-30') AS q4;
SELECT QUARTER('2007-06-15 12:30:45') AS dt_q2;
SELECT QUARTER(NULL) AS null_result;

CREATE TABLE t1(d DATE);
INSERT INTO t1 VALUES ('2007-02-01'), ('2007-05-15'), ('2007-09-10'), ('2007-12-25');
SELECT d, QUARTER(d) AS quarter_num FROM t1;
DROP TABLE t1;

DROP DATABASE quarter_demo;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: "TIME_FORMAT()"
doc_type: reference
mysql_compat: full
differs_from_mysql: []
mo_only: false
since: v3.0.15
last_updated: 2026-07-06
llms_summary: "Formats a TIME value according to a format string, using the same specifiers as DATE_FORMAT() but limited to time-related components."
---
# TIME_FORMAT()

> Formats a `TIME` value according to a format string. Uses the same specifiers as `DATE_FORMAT()`, but only time-related specifiers (`%H`, `%i`, `%s`, `%r`, `%T`, `%p`, `%f`, `%h`, `%k`, `%l`, `%I`, `%S`) are meaningful. Returns NULL if either argument is NULL.

## Function Description

The `TIME_FORMAT()` function formats a `TIME` value using format specifiers. It is the time-specific counterpart to `DATE_FORMAT()`, suitable for formatting time values without date components.

Supported format specifiers:
- `%H`: Hour (00–23)
- `%h` / `%I`: Hour (01–12)
- `%k`: Hour (0–23, without leading zero)
- `%l`: Hour (1–12, without leading zero)
- `%i`: Minutes (00–59)
- `%s` / `%S`: Seconds (00–59)
- `%p`: `AM` or `PM`
- `%r`: Time in 12-hour format (`hh:mm:ss AM/PM`)
- `%T`: Time in 24-hour format (`hh:mm:ss`)
- `%f`: Microseconds (000000–999999)

## Syntax

```
> TIME_FORMAT(time, format)
```

## Arguments

| Arguments | Description |
| ---- | ---- |
| time | Required. A `TIME` value to format. |
| format | Required. A format string containing time specifiers. Returns NULL if NULL. |

## Examples

```sql
DROP DATABASE IF EXISTS time_format_demo;
CREATE DATABASE time_format_demo;
USE time_format_demo;

SELECT TIME_FORMAT('15:30:45', '%H:%i:%s') AS basic;
SELECT TIME_FORMAT('15:30:45', '%T') AS t_format;
SELECT TIME_FORMAT('23:59:59', '%H:%i:%s') AS max_time;
SELECT TIME_FORMAT('15:30:45', '%h:%i:%s %p') AS hour12;
SELECT TIME_FORMAT('15:30:45', '%r') AS r_format;
SELECT TIME_FORMAT('00:00:00', '%r') AS midnight;
SELECT TIME_FORMAT('15:30:45.123456', '%H:%i:%s.%f') AS with_ms;
SELECT TIME_FORMAT(NULL, '%H:%i:%s') AS null_time;

CREATE TABLE t1(t TIME);
INSERT INTO t1 VALUES ('15:30:45'), ('00:00:00'), ('23:59:59'), ('12:34:56');
SELECT t, TIME_FORMAT(t, '%H:%i:%s') AS formatted FROM t1;
DROP TABLE t1;

DROP DATABASE time_format_demo;
```
33 changes: 26 additions & 7 deletions docs/MatrixOne/Reference/Functions-and-Operators/String/locate.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,42 @@ mysql_compat: full
differs_from_mysql: []
mo_only: []
since: unknown
last_updated: 2026-05-08
llms_summary: "The LOCATE() function is a function used to find the location of a substring in a string."
last_updated: 2026-07-06
llms_summary: "The LOCATE() function finds the location of a substring in a string. POSITION(substr IN str) is a synonym that does not support a start position argument."
---
# **LOCATE()**
# LOCATE()

> The LOCATE() function is a function used to find the location of a substring in a string.

## **Function Description**
## Function Description

The `LOCATE()` function is a function used to find the location of a substring in a string. It returns the position of the substring in the string or 0 if not found.

Because the `LOCATE()` function returns an integer value, it can be nested and used in other functions, such as intercepting strings with the substring function.

Regarding case, the `LOCATE()` function is case-insensitive.

## **Function syntax**
## Syntax

```
> LOCATE(subtr,str,pos)
```

## **Parameter interpretation**
`POSITION(substr IN str)` is a synonym for `LOCATE(substr, str)`. The `POSITION` form does not support a start position argument.

```
> POSITION(substr IN str)
```

## Arguments

| Parameters | Description |
| ---- | ---- |
| substr | Required parameters. `substring` is the string you are looking for. |
| str | Required parameter. `string` is the string to search in. |
| pos | Unnecessary argument. `position` is the position indicating the start of the query. |

## **Examples**
## Examples

- Example 1

Expand Down Expand Up @@ -82,4 +88,17 @@ mysql>select locate('a','ABC');
| 1 |
+----------------+
1 row in set (0.00 sec)
```

- Example 5: POSITION() syntax

<!-- validator-ignore-exec -->
```sql
mysql>SELECT POSITION('y' IN 'xyz');
+------------------------+
| position(y in xyz) |
+------------------------+
| 2 |
+------------------------+
1 row in set (0.00 sec)
```
Loading
Loading