---
title: "How to CONVERT Date INT to DATE in SQL?"  
description: "How to CONVERT Date INT to DATE in SQL?"  
author: "Utpal Vishwas"  
published: 2023-07-17  
updated: 2023-07-18  
canonical: https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql  
category: "mssql server"  
tags: ["database", "sql server", "sql"]  
reading_time: 2 minutes  

---

# How to CONVERT Date INT to DATE in SQL?

How to [CONVERT](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) Date [INT](https://www.mindstick.com/forum/161880/what-s-the-difference-between-smallint-int-and-bigint) to [DATE in SQL](https://www.mindstick.com/forum/285/how-to-convert-varchar-to-date-in-sql-server)?

## Replies

### Reply by Aryan Kumar

There are two ways to convert a [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner) integer to a date in [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database):

- **Using the** `CAST()` **function:** The `CAST()` function can be used to cast a value from one data type to another. In this case, you would cast the date integer to the `DATE` data type.

For example, the following code converts the date integer `20230718` to a date:

SQL

```plaintext
SELECT CAST(20230718 AS DATE);
```

- **Using the** `CONVERT()` **function:** The `CONVERT()` function can also be used to convert a value from one data type to another. In this case, you would specify the `DATE` data type as the output data type.

For example, the following code converts the date integer `20230718` to a date:

SQL

```plaintext
SELECT CONVERT(20230718, DATE);
```

The `CAST()` function and the `CONVERT()` function are both valid ways to convert a date integer to a date in SQL. The choice of which function to use is a matter of personal preference.

Here are some examples of how to convert a date integer to a date in SQL:

SQL

```plaintext
-- Convert a date integer to a date using the CAST() function.
SELECT CAST(20230718 AS DATE);

-- Convert a date integer to a date using the CONVERT() function.
SELECT CONVERT(20230718, DATE);
```


---

Original Source: https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
