xxxxxxxxxx
SELECT FORMAT(GETDATE(), 'yyyy-MM-dd HH:mm:ss') AS FormattedDateTime;
xxxxxxxxxx
SELECT DATE_FORMAT(DATE, '%m %d %Y') FROM table;
/*Example with now*/
SELECT DATE_FORMAT(NOW(), '%m %d %Y');
xxxxxxxxxx
-- date format
declare @dat datetime = getdate();
select FORMAT(@dat, N'yyyy-MM-dd hh:mm tt') -- returns 2022-05-09 09:35 PM
-- similar to c# .ToString("yyyy-MM-dd hh:mm tt")