As your data already in varchar, you have to convert it into date first:

select convert(varchar(10), cast(ts as date), 101) from <your table>
Answer from roman on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ func_sqlserver_convert.asp
SQL Server CONVERT() Function
SQL HOME SQL Intro SQL Syntax SQL Select SQL Select Distinct SQL Where SQL Order By SQL And SQL Or SQL Not SQL Insert Into SQL Null Values SQL Update SQL Delete SQL Select Top SQL Aggregate Functions SQL Min() SQL Max() SQL Count() SQL Sum() SQL Avg() SQL Like SQL Wildcards SQL In SQL Between SQL Aliases SQL Joins SQL Inner Join SQL Left Join SQL Right Join SQL Full Join SQL Self Join SQL Union SQL Union All SQL Group By SQL Having SQL Exists SQL Any SQL All SQL Select Into SQL Insert Into Select SQL Case SQL Null Functions SQL Stored Procedures SQL Comments SQL Operators
Discussions

t sql - How to convert a "dd/mm/yyyy" string to datetime in SQL Server? - Stack Overflow
SELECT FORMAT(CONVERT(DATETIME, '23/07/2009', 103),'dd-MM-yyyy') OUTPUT --------------- '23/07/2009' SELECT CONVERT(DATETIME, '23/07/2009', 103) OUTPUT --------------- '23/07/2009 00:00:00' ... I myself have been struggling to come up with a single query that can handle both date formats: mdy and dmy. However, you should be ok with the third date format - ymd. ... Actually, I don't believe SQL ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
T-SQL date conversion needed - datetime to mm/dd/yyyy hh:mm
Canโ€™t seem to find answer to what seems like a simple question. I have a date that is returned 2022-02-07 18:53:36.000 I need to convert that date to mm/dd/yyyy hh:mm. Is that possible? More on community.spiceworks.com
๐ŸŒ community.spiceworks.com
6
6
February 9, 2022
sql server - How to get a date in YYYY-MM-DD format from a TSQL datetime field? - Stack Overflow
Your requirement to have it in yyyy-mm-dd means it must be a string datatype and datetime. Frankly though, I'd do it on the client unless you have good reasons not to. ... Will also do trick without "chopping anything off". ... I prefer this version to avoid "year 9999" bugs associated with the convert... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Converting date format in sqlserver
So, you do not store date in SQL by any format - only displays based on the local set of your server. If you want to show dd/mm/yyyy, use the Format method or Convert / Cast on the Date field to change the format. More on learn.microsoft.com
๐ŸŒ learn.microsoft.com
4
0
November 14, 2023
๐ŸŒ
MSSQLTips
mssqltips.com โ€บ home โ€บ sql date format examples using convert function
SQL Date Format Examples using SQL CONVERT Function
September 26, 2025 - Third is an example of SQL CONVERT ... used for this example was November 12, 2023. DECLARE @Datetime DATETIME; SET @Datetime = GETDATE(); --yyyy mm dd with 4 DIGIT YEAR SELECT ......
๐ŸŒ
Tutlane
tutlane.com โ€บ article โ€บ sql-server โ€บ convert-format-datetime-in-sql-server-with-examples
Convert (Format) DateTime in SQL Server with Examples - Tutlane
By using format code 112, we can convert the given datetime to yyyymmdd format using the CONVERT function in sql server. SELECT CONVERT(VARCHAR(30), GETDATE(), 112) ------------------------------------------ 20230321 ... By using format code 103, we can convert the given datetime to dd/mm/yyyy ...
Find elsewhere
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ answers โ€บ questions โ€บ 1425205 โ€บ converting-date-format-in-sqlserver
Converting date format in sqlserver - Microsoft Q&A
November 14, 2023 - So, you do not store date in SQL by any format - only displays based on the local set of your server. If you want to show dd/mm/yyyy, use the Format method or Convert / Cast on the Date field to change the format.
๐ŸŒ
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 @d DATETIME ='2020-12-08 16:36:17.760'; SELECT FORMAT (@d,'dd/MM/yyyy ') as [Date Format 1] , FORMAT (@d, 'dd/MM/yyyy, hh:mm:ss ') as [Date Format 2] , FORMAT(@d,'yyyy-MM-dd HH:mm:ss')as [Date Format 3] , FORMAT(@d,'Dd MMM yyyy HH:mm:ss')as [Date Format 4] , FORMAT(@d,'MMM d yyyy h:mm:ss')as [Date Format 5] , FORMAT (@d, 'dddd, MMMM, yyyy')as [Date Format 6] , FORMAT (@d, 'MMM dd yyyy') as [Date Format 7] , FORMAT (@d, 'MM.dd.yy') as [Date Format 8] , FORMAT (@d, 'MM-dd-yy') as [Date Format 9] , FORMAT (@d, 'hh:mm:ss tt')as [Date Format 10] , FORMAT (@d, 'd-M-yy')as [Date Format 11] , FORMAT(@d,'MMMM dd,yyyy')as [Date Format 12]
๐ŸŒ
C# Corner
c-sharpcorner.com โ€บ article โ€บ convert-datetime-to-different-formats-in-sql-server
Mastering the Art of Convert DateTime Formats In SQL Server with Over 30 Code Examples
October 4, 2023 - By using format code as 22 we can get datetime in โ€œMM/DD/YY hh:mm:ss (AM/PM)โ€ format. ... By using format code as 23 we can get datetime in โ€œYYYY-MM-DDโ€ format.
๐ŸŒ
SQLServerCentral
sqlservercentral.com โ€บ forums โ€บ topic โ€บ convert-varchar-date-to-ddmmyyyy-format-date
Convert varchar date to dd/mm/yyyy format date โ€“ SQLServerCentral Forums
October 18, 2018 - ... select convert(date,'7/30/2016',101) or if you just want a string with that format: select convert(varchar,convert(date,'7/30/2016',101),101) Actually, I want my string "7/30/2016" to convert to 30/7/2016 ... I want to convert data that is currently in a varchar column as "7/30/2016" to ...
๐ŸŒ
SQL Shack
sqlshack.com โ€บ sql-convert-date-functions-and-formats
SQL Convert Date functions and formats
May 21, 2021 - We can combine the SQL DATEADD and CONVERT functions to get output in desired DateTime formats. Suppose, in the previous example; we want a date format in of MMM DD, YYYY.
๐ŸŒ
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
DECLARE @d1 DATE, @dt1 DATETIME , @dt2 DATETIME2 SET @d1 = '1492-08-03' --This is okay; Minimum YYYY for DATE is 0001 SET @dt2 = CAST(@d1 AS DATETIME2) --This is okay; Minimum YYYY for DATETIME2 IS 0001 SET @dt1 = CAST(@d1 AS DATETIME) --This will error with (Msg 242) "The conversion of a date data type to a datetime data type resulted in an out-of-range value."
Top answer
1 of 3
1

Hi @Raj D ,

Here is how to convert text as a DATE data type.
After that you can format it at will by using CONVERT() or FORMAT() functions.

SQL

-- DDL and sample data population, start  
DECLARE @processdata TABLE ([ProcessDate] NVARCHAR(255) NOT NULL);  
INSERT @processdata VALUES  
('Sat May 30 2020 14:19:55 GMT-0700 (Pacific Daylight Time)'),  
('Sat May 30 2020 14:19:55');  
-- DDL and sample data population, end  

  
DECLARE @separator CHAR(1) = SPACE(1);  
  
SELECT *   
 , TRY_CAST('' +   
   REPLACE([ProcessDate], @separator, '') +   
   '' AS XML)  
 .value('concat((/root/r[4]/text())[1],"-", (/root/r[2]/text())[1],"-", (/root/r[3]/text())[1])', 'DATE') AS Result  
FROM @processdata;  

;WITH rs AS  
(  
 SELECT *   
 , TRY_CAST('' +   
   REPLACE([ProcessDate], @separator, '') +   
   '' AS XML)  
 .value('concat((/root/r[4]/text())[1],"-", (/root/r[2]/text())[1],"-", (/root/r[3]/text())[1])', 'DATE') AS Result  
 FROM @processdata  
)  
SELECT *   
 , TRY_CONVERT(VARCHAR(10), rs.result, 101) AS [Converted]  
 , FORMAT(rs.result, 'MM/dd/yyyy') AS [Formatted]  
FROM rs;  

Output

+-----------------------------------------------------------+------------+  
|                        ProcessDate                        |   Result   |  
+-----------------------------------------------------------+------------+  
| Sat May 30 2020 14:19:55 GMT-0700 (Pacific Daylight Time) | 2020-05-30 |  
| Sat May 30 2020 14:19:55                                  | 2020-05-30 |  
+-----------------------------------------------------------+------------+  
2 of 3
1
SELECT try_convert(date, substring(ProcessDate, 5, 11))
FROM  @processdata

I am here assuming that month names are always three letters and dates are always two digits. To keep it simple, I'm ignoring the time part.

You should always store date and time values in proper data types; you should never store them as strings. Never!

๐ŸŒ
My Tec Bits
mytecbits.com โ€บ home โ€บ microsoft โ€บ sql server โ€บ convert datetime to yyyy-mm-dd format in sql server
Convert DateTime To YYYY-MM-DD Format In SQL Server | My Tec Bits
December 20, 2019 - DECLARE @date DateTime; SET @date = GetDate() SELECT FORMAT(@date, 'yyyy-MM-dd hh-mm-ss') As 'Date & Time', FORMAT(@date, 'MM/dd/yyyy') As 'Date in US format', FORMAT(@date, 'yyyy/MM/dd') As 'Date' GO /* Result */ Date and Time Date in US format ...
๐ŸŒ
MSSQLTips
mssqltips.com โ€บ home โ€บ sql convert date to yyyymmdd
SQL Convert Date to YYYYMMDD
May 27, 2025 - Results: Example SQL Server dates loaded. Next, converting a DATE and DATETIME datatype to character 8 โ€˜yyyymmddโ€™ output using CONVERT and FORMAT functions.