Try like this...
select CONVERT (varchar(10), getdate(), 103) AS [DD/MM/YYYY]
For more info : http://www.sql-server-helper.com/tips/date-formats.aspx
Answer from AmanKumar on Stack OverflowTry like this...
select CONVERT (varchar(10), getdate(), 103) AS [DD/MM/YYYY]
For more info : http://www.sql-server-helper.com/tips/date-formats.aspx
Changed to:
SELECT FORMAT(SA.[RequestStartDate],'dd/MM/yyyy') as 'Service Start Date', SA.[RequestEndDate] as 'Service End Date', FROM (......)SA WHERE......
Have no idea which SQL engine you are using, for other SQL engine, CONVERT can be used in SELECT statement to change the format in the form you needed.
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>
Use CONVERT with the Value specifier of 101, whilst casting your data to date:
CONVERT(VARCHAR(10), CAST(Created_TS AS DATE), 101)
How to change date format from YYMMDD to DD-MM-YYYY
sql server - How to get a date in YYYY-MM-DD format from a TSQL datetime field? - Stack Overflow
date yyyy-dd-mm in SQL 2016? – SQLServerCentral Forums
Converting date format in sqlserver
Videos
SELECT CONVERT(char(10), GetDate(),126)
Limiting the size of the varchar chops of the hour portion that you don't want.
SELECT convert(varchar, getdate(), 100) -- mon dd yyyy hh:mmAM
SELECT convert(varchar, getdate(), 101) -- mm/dd/yyyy – 10/02/2008
SELECT convert(varchar, getdate(), 102) -- yyyy.mm.dd – 2008.10.02
SELECT convert(varchar, getdate(), 103) -- dd/mm/yyyy
SELECT convert(varchar, getdate(), 104) -- dd.mm.yyyy
SELECT convert(varchar, getdate(), 105) -- dd-mm-yyyy
SELECT convert(varchar, getdate(), 106) -- dd mon yyyy
SELECT convert(varchar, getdate(), 107) -- mon dd, yyyy
SELECT convert(varchar, getdate(), 108) -- hh:mm:ss
SELECT convert(varchar, getdate(), 109) -- mon dd yyyy hh:mm:ss:mmmAM (or PM)
SELECT convert(varchar, getdate(), 110) -- mm-dd-yyyy
SELECT convert(varchar, getdate(), 111) -- yyyy/mm/dd
SELECT convert(varchar, getdate(), 112) -- yyyymmdd
SELECT convert(varchar, getdate(), 113) -- dd mon yyyy hh:mm:ss:mmm
SELECT convert(varchar, getdate(), 114) -- hh:mm:ss:mmm(24h)
SELECT convert(varchar, getdate(), 120) -- yyyy-mm-dd hh:mm:ss(24h)
SELECT convert(varchar, getdate(), 121) -- yyyy-mm-dd hh:mm:ss.mmm
SELECT convert(varchar, getdate(), 126) -- yyyy-mm-ddThh:mm:ss.mmm
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 |
+-----------------------------------------------------------+------------+
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!
The way a date is formatted in client applications like SQL Server Management Studio depends on the user's (login) settings.
Just select the login's language.

Dates and times are stored internally independent of the Culture or language settings. So there is no conversion necessary.
"Styling" your dates is in the responsibility of your programming language and should be done there.
And putting and getting dates into/from the database is possible with these tricks:
SELECT *
FROM AdventureWorks2008R2.Sales.SalesOrderHeader
WHERE OrderDate = CONVERT(DATETIME, '20060719', 101)
The following isn’t pretty and I’m 99% there is a better way to do it, but it works. The “LEFT” function was necessary because I couldn’t find a style that didn’t include the seconds.
SELECT (CONVERT(VARCHAR(20), [yourdatetimefield], 101) + ' ' + LEFT(CONVERT(VARCHAR(20), [yourdatetimefield], 108) ,5)) AS myDateTime
FROM [yourdb.yourtable]
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?