---
title: "Convert string to date in Oracle SQL?"  
description: "Convert string to date in Oracle SQL?"  
author: "Utpal Vishwas"  
published: 2023-07-17  
updated: 2023-07-18  
canonical: https://www.mindstick.com/forum/159139/convert-string-to-date-in-oracle-sql  
category: "oracle"  
tags: ["date", "string", "oracle"]  
reading_time: 2 minutes  

---

# Convert string to date in Oracle SQL?

[Convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) [string to date](https://www.mindstick.com/forum/33406/java-string-to-date-conversion) in [Oracle SQL](https://www.mindstick.com/forum/159138/oracle-sql-casting-string-as-date-how-works)?

## Replies

### Reply by Aryan Kumar

Sure, here is how you can convert a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) to a [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner) in [Oracle](https://www.mindstick.com/articles/13016/alter-table-statement-or-command-in-oracle) [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database):

SQL

```plaintext
SELECT TO_DATE('2023-07-18', 'DD-MM-YYYY');
```

This code will convert the string `2023-07-18` to a date in the format `DD-MM-YYYY`. The `TO_DATE()` function takes two arguments: the string to convert and the date format. The date format is a string that specifies the format of the string to convert.

Here is a table of some of the common date formats that you can use with the `TO_DATE()` function:

| Date Format | Description |
| --- | --- |
| `DD-MM-YYYY` | The day, month, and year in the format "DD-MM-YYYY". |
| `YYYY-MM-DD` | The year, month, and day in the format "YYYY-MM-DD". |
| `MM/DD/YYYY` | The month, day, and year in the format "MM/DD/YYYY". |
| `DD Mon YYYY` | The day, month abbreviation, and year in the format "DD Mon YYYY". |

You can also use the `TO_DATE()` function to convert a string in a custom format to a date. For example, the following code converts a string in the format "YYYYMMDD" to a date:

SQL

```plaintext
SELECT TO_DATE('20230718', 'YYYYMMDD');
```

This code would also return the date `2023-07-18`.

The `TO_DATE()` function is a powerful tool that you can use to convert different string formats into dates in Oracle. By using the `TO_DATE()` function, you can ensure that your dates are stored in a consistent format.

Here are some examples of how to use the `TO_DATE()` function:

SQL

```plaintext
-- Convert a string in the format "DD-MM-YYYY" to a date.
SELECT TO_DATE('2023-07-18', 'DD-MM-YYYY');

-- Convert a string in the format "YYYY-MM-DD" to a date.
SELECT TO_DATE('20230718', 'YYYYMMDD');

-- Convert a string in a custom format to a date.
SELECT TO_DATE('01-JAN-2023', 'DD-MON-YYYY');
```


---

Original Source: https://www.mindstick.com/forum/159139/convert-string-to-date-in-oracle-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
