SELECT CONVERT(char(10), GetDate(),126)

Limiting the size of the varchar chops of the hour portion that you don't want.

Answer from Darrel Miller on Stack Overflow
🌐
MSSQLTips
mssqltips.com › home › sql date format examples using convert function
SQL Date Format Examples using SQL CONVERT Function
September 26, 2025 - In this article, we look at how to use the SQL CONVERT function to format dates and times in over 100 different formats. ... SQL Server provides a number of date and time formatting options and in this article we look at how to use SQL CONVERT to output different date/time formats such as mm/dd/yy, mm/dd/yyyy, dd-mm-yyyy, etc.
🌐
W3Schools
w3schools.com › sql › func_sqlserver_convert.asp
SQL Server CONVERT() Function
String Functions: ASCII CHAR_LENGTH CHARACTER_LENGTH CONCAT CONCAT_WS FIELD FIND_IN_SET FORMAT INSERT INSTR LCASE LEFT LENGTH LOCATE LOWER LPAD LTRIM MID POSITION REPEAT REPLACE REVERSE RIGHT RPAD RTRIM SPACE STRCMP SUBSTR SUBSTRING SUBSTRING_INDEX TRIM UCASE UPPER Numeric Functions: ABS ACOS ASIN ATAN ATAN2 AVG CEIL CEILING COS COT COUNT DEGREES DIV EXP FLOOR GREATEST LEAST LN LOG LOG10 LOG2 MAX MIN MOD PI POW POWER RADIANS RAND ROUND SIGN SIN SQRT SUM TAN TRUNCATE Date Functions: ADDDATE ADDTIME CURDATE CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURTIME DATE DATEDIFF DATE_ADD DATE_FORMAT DA
🌐
Database Guide
database.guide › list-of-date-formats-available-with-convert-in-sql-server
List of Date Formats Available with CONVERT() in SQL Server
The following table contains a list of the date formats that you can provide to the CONVERT() function when you convert a date/time value to a string · These formats are provided as an optional third argument when calling the CONVERT() function. They’re provided as an integer expression ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › functions › format-transact-sql
FORMAT (Transact-SQL) - SQL Server | Microsoft Learn
Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric SQL database in Microsoft Fabric · Returns a value formatted with the specified format and optional culture. Use the FORMAT function for locale-aware formatting of date/time and number values as strings.
🌐
DataSunrise
datasunrise.com › home › sql server datetime formats: a comprehensive guide
SQL Server Datetime Formats
July 17, 2025 - -- Store once in UTC, present it locally DECLARE @utc DATETIME2 = SYSUTCDATETIME(); SELECT @utc AS StoredUTC, @utc AT TIME ZONE 'UTC' AT TIME ZONE 'Central European Standard Time' AS BerlinTime, @utc AT TIME ZONE 'UTC' AT TIME ZONE 'Pacific Standard Time' AS SeattleTime; Stick to ISO styles (120/121) for APIs, reserve locale-specific formats for presentation layers, and always store in UTC when rows travel across regions. Microsoft SQL Server ...
🌐
Sql-server-helper
sql-server-helper.com › tips › date-formats.aspx
SQL Server Helper - Tips and Tricks - Date Formats
SQL Server Date Formats · One of the most frequently asked questions in SQL Server forums is how to format a datetime value or column into a specific date format. Here's a summary of the different date formats that come standard in SQL Server as part of the CONVERT function.
🌐
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 114 we can get datetime in “HH:mm:ss: fff” format. ... By using format code as 120 we can get datetime in “YYYY-MM-DD HH:mm: ss” format.
Find elsewhere
🌐
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
Includes all (yy) (without century) styles and a subset of (yyyy) (with century) styles. 2 The default values (0 or 100, 9 or 109, 13 or 113, 20 or 120, 23, and 21 or 25 or 121) always return the century (yyyy).
🌐
MSSQLTips
mssqltips.com › home › format sql server dates with format function
Format SQL Server Dates with FORMAT Function
October 31, 2025 - Format SQL Date examples using SQL FORMAT Function to format dates, time and numbers in SQL Server with valuable code.
🌐
Tutlane
tutlane.com › article › sql-server › convert-format-datetime-in-sql-server-with-examples
Convert (Format) DateTime in SQL Server with Examples - Tutlane
Here is an example of how to convert a datetime value to a different format using the CONVERT function in the SQL server. SELECT CONVERT(VARCHAR(30), GETDATE(), 120) ------------------------------------------- 2023-03-21 07:52:59
🌐
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 - declare @Your_Data_Here as datetime ... then 'YY MM DD' when starts = 'MMM' and charindex('2001',Styled_Date) > 1 then 'MMM DD YYYY' when starts = 'MMM' and charindex('2001',Styled_Date) < 1 then 'MMM DD YY' when starts = ...
🌐
DB Vis
dbvis.com › thetable › the-ultimate-guide-to-the-sql-server-date-format
The Ultimate Guide to the SQL Server Date Format
October 23, 2024 - In this guide, you will see standard date formats, explore the date components supported by T-SQL, and understand how to use the FORMAT SQL Server date function.
🌐
Quest Blog
blog.quest.com › home › various ways to use the sql convert date function
SQL CONVERT date formats and functions
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 Shack
sqlshack.com › sql-convert-date-functions-and-formats
SQL Convert Date functions and formats
May 21, 2021 - SYSDATETIMEOffset(): It returns the server’s date and time, along with UTC offset · GETUTCDATE(): It returns date and GMT (Greenwich Mean Time ) time ... Execute the following queries to get output in respective formats. As highlighted earlier, we might need to format a date in different formats as per our requirements. We can use the SQL CONVERT() function in SQL Server to format DateTime in various formats.
🌐
Coffingdw
coffingdw.com › how-to-format-dates-in-sql-server-over-1800-examples-included
How to Format Dates in SQL Server – Over 1800 Examples Included – Software connecting all databases
This blog will brilliantly break down and explain everything about the formatting dates in any way you desire on an Azure Synapse or SQL Server system. I will include over 1800 examples to avoid confusion about formatting dates. Azure Synapse and SQL Server use two ways to format dates: the CONVERT and FORMAT functions to transform raw dates as you want them presented.
Top answer
1 of 10
27

Use DATENAME and wrap the logic in a Function, not a Stored Proc

declare @myTime as DateTime

set @myTime = GETDATE()

select @myTime

select DATENAME(day, @myTime) + SUBSTRING(UPPER(DATENAME(month, @myTime)), 0,4)

Returns "14OCT"

Try not to use any Character / String based operations if possible when working with dates. They are numerical (a float) and performance will suffer from those data type conversions.

Dig these handy conversions I have compiled over the years...

/* Common date functions */
--//This contains common date functions for MSSQL server

/*Getting Parts of a DateTime*/
    --//gets the date only, 20x faster than using Convert/Cast to varchar
    --//this has been especially useful for JOINS
    SELECT (CAST(FLOOR(CAST(GETDATE() as FLOAT)) AS DateTime))

    --//gets the time only (date portion is '1900-01-01' and is considered the "0 time" of dates in MSSQL, even with the datatype min value of 01/01/1753. 
    SELECT (GETDATE() - (CAST(FLOOR(CAST(GETDATE() as FLOAT)) AS DateTime)))


/*Relative Dates*/
--//These are all functions that will calculate a date relative to the current date and time
    /*Current Day*/
    --//now
    SELECT (GETDATE())

    --//midnight of today
    SELECT (DATEADD(ms,-4,(DATEADD(dd,DATEDIFF(dd,0,GETDATE()) + 1,0))))

    --//Current Hour
    SELECT DATEADD(hh,DATEPART(hh,GETDATE()),CAST(FLOOR(CAST(GETDATE() AS FLOAT)) as DateTime))

    --//Current Half-Hour - if its 9:36, this will show 9:30
    SELECT DATEADD(mi,((DATEDIFF(mi,(CAST(FLOOR(CAST(GETDATE() as FLOAT)) as DateTime)), GETDATE())) / 30) * 30,(CAST(FLOOR(CAST(GETDATE() as FLOAT)) as DateTime)))

    /*Yearly*/
    --//first datetime of the current year
    SELECT (DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0))

    --//last datetime of the current year
    SELECT (DATEADD(ms,-4,(DATEADD(yy,DATEDIFF(yy,0,GETDATE()) + 1,0))))

    /*Monthly*/
    --//first datetime of current month
    SELECT (DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))

    --//last datetime of the current month
    SELECT (DATEADD(ms,-4,DATEADD(mm,1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))))

    --//first datetime of the previous month
    SELECT (DATEADD(mm,DATEDIFF(mm,0,GETDATE()) -1,0))

    --//last datetime of the previous month
    SELECT (DATEADD(ms, -4,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)))

    /*Weekly*/
    --//previous monday at 12AM
    SELECT (DATEADD(wk,DATEDIFF(wk,0,GETDATE()) -1 ,0))

    --//previous friday at 11:59:59 PM
    SELECT (DATEADD(ms,-4,DATEADD(dd,5,DATEADD(wk,DATEDIFF(wk,0,GETDATE()) -1 ,0))))

    /*Quarterly*/
    --//first datetime of current quarter
    SELECT (DATEADD(qq,DATEDIFF(qq,0,GETDATE()),0))

    --//last datetime of current quarter
    SELECT (DATEADD(ms,-4,DATEADD(qq,DATEDIFF(qq,0,GETDATE()) + 1,0)))
2 of 10
23

You can use the following command in SQL server to make it:

select FORMAT(getdate(), N'yyyy-MM-ddThh:mm:ss')
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › statements › set-dateformat-transact-sql
SET DATEFORMAT (Transact-SQL) - SQL Server | Microsoft Learn
For the default DATEFORMAT of all support languages, see sp_helplanguage (Transact-SQL). The DATEFORMAT ydm isn't supported for date, datetime2, and datetimeoffset data types. The DATEFORMAT setting may interpret character strings differently for date data types, depending on their string format.
🌐
TablePlus
tableplus.com › blog › 2018 › 09 › sql-server-date-format-cheatsheet.html
SQL Server Date Format Cheatsheet | TablePlus
September 13, 2018 - In this post, we are going to introduce all the date formats, as long as the corresponding CONVERT() statement in SQL Server.