The last argument of CONVERT seems to determine the format used for parsing. Consult MSDN docs for CONVERT.

111 - the one you are using is Japan yy/mm/dd.

I guess the one you are looking for is 103, that is dd/mm/yyyy.

So you should try:

 SELECT convert(datetime, '23/07/2009', 103)
Answer from Grzegorz Oledzki on Stack Overflow
Discussions

sql - Converting string 'yyyy-mm-dd' to date - Stack Overflow
I want to select from table where date column is equal to specific date which I sending as a string in format 'yyyy-mm-dd'. I need to convert that string and than to compare if I have that date in my More on stackoverflow.com
🌐 stackoverflow.com
Convert varchar date to dd/mm/yyyy format date – SQLServerCentral Forums
Convert varchar date to dd/mm/yyyy format date Forum – Learn more on SQLServerCentral More on sqlservercentral.com
🌐 sqlservercentral.com
October 18, 2018
sql server - Converting a varchar date into a date (dd/mm/yy) - Database Administrators Stack Exchange
I have a CSV file that has dates written like this: 250909,240909 and they get stored in a SQL Server database as varchars. How do I get it to convert them into dates so that it gets displayed lik... More on dba.stackexchange.com
🌐 dba.stackexchange.com
Convert column with data MM/DD/YYYY varchar to date in sql server? - Stack Overflow
I'm very much a novice with little SQL experience. I have a column END_DATE as Varchar(10) where all the rows follow the mm/dd/yyyy format and I would like to convert it to date. I have an empty column formatted as date if that helps. There are 36 million rows. ... UPDATE YourTable SET YourNewColumn = CONVERT(DATETIME... More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › sql › func_sqlserver_convert.asp
SQL Server CONVERT() Function
SELECT CONVERT(varchar, 25.65); Try it Yourself » · Convert an expression from one data type to another (datetime): SELECT CONVERT(datetime, '2017-08-25'); Try it Yourself » · Convert an expression from one data type to another (varchar): SELECT CONVERT(varchar, '2017-08-25', 101); Try it Yourself » ·
🌐
MSSQLTips
mssqltips.com › home › sql date format examples using convert function
SQL Date Format Examples using SQL CONVERT Function
September 26, 2025 - DECLARE @Datetime DATETIME; SET @Datetime = GETDATE(); --mm/dd/yyyy with 4 DIGIT YEAR SELECT CONVERT(VARCHAR(10), @Datetime, 101) CurrentDateFormattedAsText; --mm/dd/yy with 2 DIGIT YEAR SELECT CONVERT(VARCHAR(8), @Datetime, 1) CurrentDateF...
🌐
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 ...
Top answer
1 of 3
5

I understand your problem to be how to successfully convert the string into a DATE value. An undelimited string of integers is assumed to be Year-Month-Day order. (And, of course, I agree with the comments that dates should be stored in DATE data types in the database.)

Reviewing the MSDN CONVERT documentation does not show a built-in conversion for your string, but it is easy to work around.

http://msdn.microsoft.com/en-us/library/ms187928.aspx -- CAST and CONVERT

I changed the month to 8 to make it easier to double check. Using the CONVERT style option 3, you can do the following:

DECLARE @String VARCHAR(10);
DECLARE @DateValue DATE;
SET @String = '250809'; 

-- Convert your undelimited string DDMMYY into a DATE
-- First: Add / between the string parts.
SET @STRING = SUBSTRING(@String,1,2)+'/'+
     SUBSTRING(@String,3,2)+'/'+SUBSTRING(@String,5,2);
-- Second: Convert using STYLE 3 to get DD/MM/YY interpretation
SELECT @DateValue = CONVERT(Date, @String, 3);

-- Using the DATE 
-- Select the value in default Year-Month-Day
SELECT @DateValue AS DefaultFormat;    
-- Select the value formatted as dd/mm/yy
SELECT CONVERT(VARCHAR(20),@DateValue,3) AS [DD/MM/YY];

The results of the last two selects are:

DefaultFormat
-------------
2009-08-25

DD/MM/YY
--------
25/08/09

To get your DATE formatted in the way you want it, you have to insert the '/' delimiters then use the STYLE 3 in converting from the string to the DATE. (I am sure that there are other workarounds and conversion styles that would work as well.)

Likewise when displaying the DATE as you desire, you need to use STYLE 3

2 of 3
3

Another approach is to cast it directly to a date in SQL Server 2008 or above, then store it that way as @ypercube commented above. Assuming 2000 <= all expected years <= 2099:

DECLARE @d CHAR(6) = '250909';
SELECT DATEFROMPARTS('20'+RIGHT(@d,2),SUBSTRING(@d,3,2),LEFT(@d,2));

You may need to do things a little differently if you could have 250999 etc, then you would need some way to indicate whether that's 1999 or 2099, for example. This also doesn't handle validation (like the other answer, it will choke on values like 252525).

When you want to display the date, then format it at the display/presentation layer, but store it correctly in the database. I still question whether it is actually useful to display as ambiguous formats like 25/09/2009 - for that date specifically it's clearly September 25th, but are you sure your entire audience will always get 07/08/2009 correctly? While I'm in the USA that's July 8th, but last week I was in Canada, and I would expect that to be August 7th. Output formats like 2009-07-08 are much clearer and less prone to misinterpretation; even better would be July 8th, 2009 - but then that opens the door to folks using a different language. All that said, these formats can be completely controlled by the client application (C# has very powerful formatting functions), and shouldn't dictate how you actually store the data in the database. They should be stored as dates because you get automatic validation, all of the date/time functionality, etc. Stop storing dates as strings (and maybe even try to get the CSV to contain more reliable literal formats, like YYYYMMDD). Some useful reading perhaps:

  • https://sqlblog.org/2009/10/12/bad-habits-to-kick-choosing-the-wrong-data-type

  • https://sqlblog.org/2009/10/16/bad-habits-to-kick-mis-handling-date-range-queries

🌐
TablePlus
tableplus.com › blog › 2019 › 09 › convert-varchar-to-date-sql.html
How to convert varchar to date in SQL Server? | TablePlus
September 10, 2019 - To convert a varchar string value ... Here is the list of style values that you can use in the CONVERT statement: ... Read more on how to use the CAST() function. ... With the style 101 (mm/dd/yyyy), the string value 09/10/2019 is now a datetime value....
Find elsewhere
🌐
Tutlane
tutlane.com › article › sql-server › convert-format-datetime-in-sql-server-with-examples
Convert (Format) DateTime in SQL Server with Examples - Tutlane
SELECT CONVERT(VARCHAR(30), GETDATE(), 103) ------------------------------------------ 21/03/2023 ... By using format code 29, we can convert the given datetime to dd-mm-yyyy hh:mm:ss:nnn format.
🌐
Experts Exchange
experts-exchange.com › questions › 29056419 › SQL-Convert-nvarchar-to-datetime-MM-DD-YYYY-format.html
Solved: SQL - Convert nvarchar to datetime "MM/DD/YYYY" format | Experts Exchange
September 13, 2017 - Is that month 8, or month 9? ... ... NVARCHAR so the user can insert anything. .. SELECT CONVERT(VARCHAR(12), YourDateColumn, 1) FROM yourtable WHERE ISDATE(YourDateColumn) = 1...
🌐
Reddit
reddit.com › r/sql › converting varchar to datetime
r/SQL on Reddit: Converting varchar to DATETIME
May 10, 2021 -

Hi guys, SQL novice here - I was hoping for a little help. I have this Pivot table query from SQhint which is exactly what I need . Unfortunately, my column for the date source is varchar type and not date time, however the data is formatted as YYYYMMDD (eg. 20200120). Google says I can use CASE or CONVERT but I am not sure exactly how to implement it with this query. Any help is greatly appreciated.

https://sqlhints.com/tag/sql-group-by-month-and-year/

SELECT *
FROM (SELECT YEAR(SalesDate) [Year], 
       DATENAME(MONTH, SalesDate) [Month], 
       COUNT(1) [Sales Count]
      FROM #Sales
      GROUP BY YEAR(SalesDate), 
      DATENAME(MONTH, SalesDate)) AS MontlySalesData
PIVOT( SUM([Sales Count])   
    FOR Month IN ([January],[February],[March],[April],[May],
    [June],[July],[August],[September],[October],[November],
    [December])) AS MNamePivot
🌐
CodingSight
codingsight.com › home › converting datetime to yyyy-mm-dd format in sql server
How to Convert DateTime to Date Format in SQL Server
July 24, 2023 - We learned to use the CAST function to convert different data types including DateTime and strings to YYYY-MM-DD format and the CONVERT function to turn the YYYY-MM-DD dates to other formats.
🌐
Stack Exchange
dba.stackexchange.com › questions › 252977 › how-to-convert-a-varchar-dd-mm-yyyy-hmmss-am-into-datetime-and-then-to-json-da
sql server 2014 - How to convert a VARCHAR DD/MM/YYYY H:MM:SS AM into datetime and then to Json date? - Database Administrators Stack Exchange
November 11, 2019 - I tested above command against a SQL Server 2014 and it works when you omit leading zeroes - and also with AM / PM addition so perfect for your case · The only thing that needs some more work is your desired addition of the timezone, but I highly suggest adding that only for display, not in the actual database ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 0 the result of REPLACE and CONVERT is a VARCHAR(8000) - how can I have a VARCHAR(50) as a result instead?
🌐
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
When you convert between datetimeoffset and the character types char, nchar, nvarchar, and varchar, the converted time zone offset part should always have double digits for both HH and MM.
🌐
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.