# STR\_TO\_DATE

Extract datetime value from input string according to a specified format.

## Syntax

```
STR_TO_DATE (str, format)

```

## Arguments

* str: a valid date, datetime, or time, formatted according to the specified format string
* format: a string containing format symbols

See [DATE\_FORMAT](https://docs.singlestore.com/db/v9.1/reference/sql-reference/date-and-time-functions/date-format.md) for a description of format symbols.

## Return Type

String

## Examples

```sql
SELECT STR_TO_DATE('March 3rd, 2015', '%M %D, %Y');

```

```output

+---------------------------------------------+
| STR_TO_DATE('March 3rd, 2015', '%M %D, %Y') |
+---------------------------------------------+
| 2015-03-03                                  |
+---------------------------------------------+

```

```sql
SELECT STR_TO_DATE('2015-03-03 11:37:07', '%Y-%m-%d %h:%i:%s');

```

```output

+---------------------------------------------------------+
| STR_TO_DATE('2015-03-03 11:37:07', '%Y-%m-%d %h:%i:%s') |
+---------------------------------------------------------+
| 2015-03-03 11:37:07                                     |
+---------------------------------------------------------+
```

```sql
SELECT STR_TO_DATE('Tuesday, the 3rd day of March in that remarkable year 2015', '%W, the %D day of %M in that remarkable year %Y') AS florid;

```

```output

+------------+
| florid     |
+------------+
| 2015-03-03 |
+------------+
```

***

Modified at: May 31, 2023

Source: [/db/v9.1/reference/sql-reference/date-and-time-functions/str-to-date/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/date-and-time-functions/str-to-date/)

(An index of the documentation is available at /llms.txt)
