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 OverflowMicrosoft Learn
learn.microsoft.com โบ en-us โบ sql โบ t-sql โบ functions โบ cast-and-convert-transact-sql
CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
An integer expression that specifies how the CONVERT function will translate expression. For a style value of NULL, NULL is returned. data_type determines the range. Returns expression, translated to data_type. For a date or time data type expression, style can have one of the values shown in the following table.
MSSQLTips
mssqltips.com โบ home โบ sql date format examples using convert function
SQL Date Format Examples using SQL CONVERT Function
September 26, 2025 - Learn how to use SQL CONVERT for different SQL date format options and achieve the desired date representation.
Videos
13:44
MS SQL tutorial on CONVERT and CAST functions - YouTube
09:05
SQL | How to Convert Date / Time Formats ? | Convert | Format - ...
08:36
How to Convert VARCHAR to Date in SQL Server - YouTube
00:48
Convert datetime to date in SQL - YouTube
28:31
59. DATE Format in SQL - Use SQL Convert with Date Format in SQL ...
15:16
60. More DATE Format in SQL - Use SQL Convert with Date Format ...
W3Schools
w3schools.com โบ sql โบ func_sqlserver_convert.asp
SQL Server CONVERT() Function
String Functions: Asc Chr Concat ... Plan SQL Bootcamp SQL Certificate SQL Training ... The CONVERT() function converts a value (of any type) into a specified datatype....
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)'
DotFactory
dofactory.com โบ sql โบ convert-datetime-to-date
SQL Convert DATETIME to DATE
GETDATE returns the current database server's datetime. CONVERT converts the datetime value to a date format.
GeeksforGeeks
geeksforgeeks.org โบ sql โบ sql-query-to-convert-datetime-to-date
SQL Query to Convert DateTime to Date in SQL Server - GeeksforGeeks
Aggregating by Date: For example, when calculating daily totals or averages, you may want to group data by date only, ignoring the time part. The aim of this article data is to convert DateTime to Date in SQL Server like YYYY-MM-DD HH:MM: SS to YYYY-MM-DD.
Published ย July 23, 2025
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
DB Vis
dbvis.com โบ thetable โบ extracting-time-and-date-in-ms-sql-server-a-comprehensive-guide
Extract Date and Time in MS SQL Server: A Complete Guide
February 7, 2025 - This will return the time portion in the format hh:mm:ss AM/PM. If the datetime value is 2023-3-01 11:50:05.627, the result will be 11:50:05 AM. The above query first converts the datetime value to a string using style 109, which includes the date and time in the format mon dd yyyy hh:mi:ss:mmmAM.
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 - DECLARE @InputDate DATETIME = '2020-12-08 15:58:17.643' SELECT 'd' AS [FormatCode], 'Short Date Pattern' AS 'Pattern', Format(@InputDate, 'd') AS 'Output' UNION ALL SELECT 'D' AS [FormatCode], 'Long Date Pattern' AS 'Pattern', Format(@InputDate, 'D') AS 'Output' UNION ALL SELECT 'f' AS [FormatCode], 'Full Date/Time pattern (Short Time)' AS 'Pattern', Format(@InputDate, 'f') AS 'Output' UNION ALL SELECT 'F' AS [FormatCode], 'Full Date/Time pattern (Long Time)' AS 'Pattern', Format(@InputDate, 'F') UNION ALL SELECT 'g' AS [FormatCode], 'General Date/Time pattern (Short Time)' AS 'Pattern', Forma
SQL Server Tutorial
sqlservertutorial.net โบ home โบ sql server system functions โบ convert datetime to date
Convert Datetime to Date in SQL Server By Practical Examples
April 11, 2020 - To convert a datetime to a date, you can use the CONVERT(), TRY_CONVERT(), or CAST() function.
Top answer 1 of 3
2
Don't use FORMAT it's slow, and should only be used if you have no choice.
Just use CONVERT with style 112.
select convert(char(8), @d, 112);
db<>fiddle
Having said that, I'd advise you not to save that into a column. Dates should be kept in date formats, not varchar, until you actually need to query it.
At the most, you could use a computed column
ALTER TABLE YourTable
ADD FormattedDate AS ( CONVERT(char(8), YourDateColumn, 112) )
2 of 3
0
You can use the format, but my recommend is to use the DimDate(Table Date) and where clause with date and use dateint in select
Select format(cast(GETDATE() as date),'yyyyMMdd') --20230626
Select format(cast('2023/11/05' as date),'yyyyMMdd') --20231105
Stack Overflow
stackoverflow.com โบ questions โบ 74053120 โบ sql-server-convert-datetime-to-yyyy-mm-ddthhmmss-sssz
Sql server convert datetime to ''YYYY-MM-DD'T'HH:mm:ss.SSS'Z" - Stack Overflow
Select Convert(varchar,start_date,126)+'.000Z' as required_date from Table1 Select Convert(varchar,start_date,127)+'.000Z' as required_date from Table1
SQLines
sqlines.com โบ sql-server-to-mysql โบ functions โบ convert_datetime
SQL Server CONVERT for Datetime in MySQL - SQLines Tools
In SQL Server, you can use CONVERT function to convert a string with the specified format to a DATETIME value. In MySQL, you can use STR_TO_DATE function if you need a specific format, or CONVERT if you need the default format. Note that the order of parameters in SQL Server and MySQL CONVERT ...