Try this

Cast('7/7/2011' as datetime)

and

Convert(DATETIME, '7/7/2011', 101)

See CAST and CONVERT (Transact-SQL) for more details.

Answer from gauravg on Stack Overflow
🌐
W3Schools
w3schools.com › sql › func_sqlserver_convert.asp
SQL Server CONVERT() Function
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Certificate SQL Training ... The CONVERT() function converts a value (of any type) into a specified datatype.
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › functions › cast-and-convert-transact-sql
CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
Reference for the CAST and CONVERT Transact-SQL functions. These functions convert expressions from one data type to another.
Discussions

t sql - Sql Server string to date conversion - Stack Overflow
I want to convert a string like this: '10/15/2008 10:06:32 PM' into the equivalent DATETIME value in Sql Server. In Oracle, I would say this: TO_DATE('10/15/2008 10:06:32 PM','MM/DD/YYYY HH:MI:S... More on stackoverflow.com
🌐 stackoverflow.com
sql server - T-SQL Cast versus Convert - Stack Overflow
What is the general guidance on when you should use CAST versus CONVERT? Is there any performance issues related to choosing one versus the other? Is one closer to ANSI-SQL? More on stackoverflow.com
🌐 stackoverflow.com
How to use Convert?

ON convert(date, timestamp) = convert(date, create date)

More on reddit.com
🌐 r/SQL
4
3
July 15, 2023
Should i convert my CSV files into SQL tables?

What’s your goal? If you are doing one-off data analysis it really doesn’t matter if you load the CSVs into a db or not. If you’re trying to build a portfolio project for data engineering, loading them into a db is a great idea as it shows you are capable of that type of work.

If you’re unfamiliar, SQLite is a really great db for small projects, as the entire db is kept in a single file.

More on reddit.com
🌐 r/dataengineering
12
10
March 25, 2021
🌐
Mimo
mimo.org › glossary › sql › convert-function
SQL CONVERT Function: Syntax, Usage, and Examples
The SQL CONVERT function changes the data type of a value to another, such as converting a number to a string or a string to a date.
🌐
Towards Data Science
towardsdatascience.com › home › latest › building a like-for-like solution for stores in power bi
Building a Like-for-Like solution for Stores in Power BI | Towards Data Science
2 days ago - I do this in the SQL query to retrieve the fact data: SELECT [F].[SaleLineCounter] AS [Sale Line Counter] ,CONVERT(date, DATEADD(yyyy, 16, [F].[DateKey])) AS [DateKey] ,[F].[channelKey] ,[F].[StoreKey] ,CONCAT(CONVERT(nvarchar(25), [F].[StoreKey]) ,'_' ,CONVERT(nvarchar(25), YEAR(CONVERT(date, DATEADD(yyyy, 16, [F].[DateKey])))) ,RIGHT('00' + CONVERT(nvarchar(25), MONTH(CONVERT(date, DATEADD(yyyy, 16, [F].[DateKey])))), 2) ) AS [StoreMonthKey] ,[F].[ProductKey] ,[F].[PromotionKey] ,[F].[CurrencyKey] ,[F].[UnitCost] ,[F].[UnitPrice] ,[F].[SalesQuantity] ,[F].[ReturnQuantity] ,[F].[ReturnAmount] ,[F].[DiscountQuantity] ,[F].[DiscountAmount] ,[F].[TotalCost] ,[F].[SalesAmount] ,[F].[DateKeyYear] FROM [dbo].[v_FactSales] AS [F];
Top answer
1 of 16
368

Try this

Cast('7/7/2011' as datetime)

and

Convert(DATETIME, '7/7/2011', 101)

See CAST and CONVERT (Transact-SQL) for more details.

2 of 16
62

Run this through your query processor. It formats dates and/or times like so and one of these should give you what you're looking for. It wont be hard to adapt:

Declare @d datetime
select @d = getdate()

select @d as OriginalDate,
convert(varchar,@d,100) as ConvertedDate,
100 as FormatValue,
'mon dd yyyy hh:miAM (or PM)' as OutputFormat
union all
select @d,convert(varchar,@d,101),101,'mm/dd/yy'
union all
select @d,convert(varchar,@d,102),102,'yy.mm.dd'
union all
select @d,convert(varchar,@d,103),103,'dd/mm/yy'
union all
select @d,convert(varchar,@d,104),104,'dd.mm.yy'
union all
select @d,convert(varchar,@d,105),105,'dd-mm-yy'
union all
select @d,convert(varchar,@d,106),106,'dd mon yy'
union all
select @d,convert(varchar,@d,107),107,'Mon dd, yy'
union all
select @d,convert(varchar,@d,108),108,'hh:mm:ss'
union all
select @d,convert(varchar,@d,109),109,'mon dd yyyy hh:mi:ss:mmmAM (or PM)'
union all
select @d,convert(varchar,@d,110),110,'mm-dd-yy'
union all
select @d,convert(varchar,@d,111),111,'yy/mm/dd'
union all
select @d,convert(varchar,@d,12),12,'yymmdd'
union all
select @d,convert(varchar,@d,112),112,'yyyymmdd'
union all
select @d,convert(varchar,@d,113),113,'dd mon yyyy hh:mm:ss:mmm(24h)'
union all
select @d,convert(varchar,@d,114),114,'hh:mi:ss:mmm(24h)'
union all
select @d,convert(varchar,@d,120),120,'yyyy-mm-dd hh:mi:ss(24h)'
union all
select @d,convert(varchar,@d,121),121,'yyyy-mm-dd hh:mi:ss.mmm(24h)'
union all
select @d,convert(varchar,@d,126),126,'yyyy-mm-dd Thh:mm:ss:mmm(no spaces)'
🌐
DB Vis
dbvis.com › thetable › sql-convert-the-handbook-of-data-conversion-in-sql-2
SQL CONVERT: The Handbook of Data Conversion in SQL
May 2, 2024 - In SQL, CONVERT is an SQL function to convert a value from one data type to another. Since it is not a standard SQL function, the implementation of CONVERT may vary between different database systems.
Find elsewhere
🌐
InfluxData
influxdata.com › home › how does date conversion work in sql? | influxdata
How Does Date Conversion Work in SQL? | InfluxData
October 6, 2023 - So, a SQL database with a date and time of "08/15/2023 23:20:30" can be read as invalid for a format of "DD/MM/YYYY" as there is no "15" month in the Gregorian calendar. --Wrong format Declare @date_time_value varchar(100)= '08/15/2023 23:20:30' select CONVERT(datetime2, @date_time_value, 103) as Date;
🌐
Oracle
docs.oracle.com › en › database › oracle › oracle-database › 18 › sqlrf › CONVERT.html
SQL Language Reference
January 4, 2023 - Oracle discourages the use of the CONVERT function in the current Oracle Database release. The return value of CONVERT has a character data type, so it should be either in the database character set or in the national character set, depending on the data type.
🌐
TechOnTheNet
techonthenet.com › sql_server › functions › convert.php
SQL Server: CONVERT Function
In SQL Server (Transact-SQL), the CONVERT function converts an expression from one datatype to another datatype. If the conversion fails, the function will return an error.
🌐
Quest Blog
blog.quest.com › home › various ways to use the sql convert date function
Various ways to use the SQL CONVERT date function
April 26, 2024 - Learn how to use the SQL CONVERT date function to get the specific date format you need, as they can vary between different countries.
🌐
RudderStack
rudderstack.com › guides › how-to-sql-type-casting
SQL type casting: How to Get Started? | RudderStack
The CONVERT() function takes as input the current valid expression and the target data type and performs the appropriate conversion. ... Regarding the supported representation styles, MS SQL Server offers a quite large variety as shown in the ...
🌐
Reddit
reddit.com › r/sql › how to use convert?
r/SQL on Reddit: How to use Convert?
July 15, 2023 -

Hey all, I’m trying to understand Convert. For reference I have 0 computer science training and I can do BASIC queries for searching as part of my job.

So more details - I have 3 tables. A stock price table, a table that records stock price awards (grant table) for a person, and an activity table that records different events on that stock award. Grant and activity table can be joined by GRANT_ID.

What I’m trying to do in with a select query is assign a stock price to certain activities (not via insert). my create date on the activity table is a timestamp (ex: 05-APR-24 12.00.00.0000000) as is the create date on the stock price table. My problem is that if I join the stock price table and activity table by dates nothing will happen because of the timestamp, they won’t match. And I don’t care about the time, I just care about the date portion.

So- would CONVERT help me at all? And if so, how do I just do something like “join stock price table and activity table where the Dates only match, not the time”

I hope I’m making a shred of sense, thanks in advance!

🌐
MSSQLTips
mssqltips.com › home › sql date format examples using convert function
SQL Date Format Examples using SQL CONVERT Function
September 26, 2025 - I want to convert a Text Field which is saving the Data in String into a Date field. The value stored is in the below format. Value Stored = 66028 Actual Value (or) Desired Output = 10-11-2021 (dd-mm-yyyy) ... you could create another table with the mapping and then join to that table based on the day of the month to return your A, B, C, etc. values. ... Hello, i am beginner in sql i have one task of conversion of date like.
🌐
AWS
docs.aws.amazon.com › aws database migration service › microsoft sql server 2019 to amazon aurora postgresql migration playbook › migrating t-sql features › sql server cast and convert for t-sql
SQL Server cast and convert for T-SQL - SQL Server to Aurora PostgreSQL Migration Playbook
This topic provides reference information about data type conversion and casting in Amazon Aurora PostgreSQL compared to Microsoft SQL Server. You can understand the similarities and differences between the CAST and CONVERT functions in both database systems.
🌐
MariaDB
mariadb.com › docs › server › reference › sql-functions › string-functions › convert
CONVERT | Server | MariaDB Documentation
January 28, 2026 - CONVERT() with USING is used to convert data between different character sets. In MariaDB, transcoding names are the same as the corresponding character set names.
🌐
Experts Exchange
experts-exchange.com › articles › 12315 › SQL-Server-Date-Styles-formats-using-CONVERT.html
SQL Server Date Styles (formats) using CONVERT() | Experts Exchange
October 3, 2013 - DELIMITED STARTS PATTERN STYLED DATE SYNTAX STYLE LENGTH YYYY YYYY MM DD 20010223 convert(varchar, your_data_here ,112) 112 8 YY YY MM DD 010223 convert(varchar, your_data_here ,12) 12 6 slash YYYY YYYY MM DD 2001/02/23 convert(varchar, your_data_here ,111) 111 10 slash YY YY MM DD 01/02/23 convert(varchar, your_data_here ,11) 11 8 slash MM MM DD YYYY 02/23/2001 convert(varchar, your_data_here ,101) 101 10 slash MM MM DD YY 02/23/01 convert(varchar, your_data_here ,1) 1 8 slash DD DD MM YYYY 23/02/2001 convert(varchar, your_data_here ,103) 103 10 slash DD DD MM YY 23/02/01 convert(varchar, you
🌐
TutorialsTeacher
tutorialsteacher.com › sqlserver › convert-function
SQL Server CONVERT() Function
SQL Server CONVERT() function converts an expression of one data type to another data type.
🌐
InterSystems
docs.intersystems.com › irislatest › csp › docbook › DocBook.UI.Page.cls
CONVERT (SQL) | InterSystems SQL Reference | InterSystems IRIS Data Platform 2025.3
February 22, 2022 - When converting to an integer data type or the SQL_DOUBLE data type, the CONVERT function converts data values (including dates and times) to a numeric representation. For SQL_DATE, this is the number of days since January 1, 1841.