You can use the STUFF() method to insert characters into your string to format it in to a value SQL Server will be able to understand:

DECLARE @datestring NVARCHAR(20) = '20120225143620'

-- desired format: '20120225 14:36:20'
SET @datestring = STUFF(STUFF(STUFF(@datestring,13,0,':'),11,0,':'),9,0,' ')

SELECT CONVERT(DATETIME, @datestring) AS FormattedDate

Output:

FormattedDate
=======================
2012-02-25 14:36:20.000

This approach will work if your string is always the same length and format, and it works from the end of the string to the start to produce a value in this format: YYYYMMDD HH:MM:SS

For this, you don't need to separate the date portion in anyway, as SQL Server will be able to understand it as it's formatted.

Related Reading:

STUFF (Transact-SQL)

The STUFF function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.

STUFF ( character_expression , start , length , replaceWith_expression )

Answer from Tanner on Stack Overflow
🌐
SQLines
sqlines.com › oracle-to-sql-server › to_date
TO_DATE - Convert String to Datetime - Oracle to SQL Server Migration - SQLines Tools
In Oracle, TO_DATE function converts a string value to DATE data type value using the specified format. In SQL Server, you can use CONVERT or TRY_CONVERT function with an appropriate datetime style. Oracle: -- Specify a datetime string and its exact format SELECT TO_DATE('2012-06-05', 'YYYY-MM-DD') ...
🌐
MSSQLTips
mssqltips.com › home › sql date format examples using convert function
SQL Date Format Examples using SQL CONVERT Function
September 26, 2025 - --SELECT a datetime column as a string formatted dd/mm/yyyy (4 digit year) SELECT TOP 3 CONVERT(CHAR(10), ExpectedDeliveryDate, 103) ExpectedDeliveryDateFormattedAsText FROM Purchasing.PurchaseOrders WHERE OrderDate < @Datetime; --SELECT a datetime column as a string formatted dd/mm/yy (2 digit year) SELECT TOP 3 CONVERT(CHAR(8), ExpectedDeliveryDate, 3) ExpectedDeliveryDateFormattedAsText FROM Purchasing.PurchaseOrders WHERE OrderDate < @Datetime; Once the query runs, review SQL CONVERT output as shown below.
🌐
Spiceworks
community.spiceworks.com › programming & development › databases & queries
Date format YYYYMMDDHHMMSS - Databases & Queries - Spiceworks Community
February 8, 2005 - Dear Everyone Can somebody help ... without the “”-“” & “”:“”. Though we can only do this:- select CONVERT(char(8), getdate(), 112) & would result to 20050208....
Find elsewhere
🌐
SQLServerCentral
sqlservercentral.com › forums › topic › how-to-get-yyyymmddhhmmss
How to get YYYYMMDDHHMMSS – SQLServerCentral Forums
October 21, 2021 - SELECT YYYYMMDDHHMISS = CONVERT(CHAR(14), CONVERT(BIGINT,CONVERT(CHAR(8),GETDATE(),112))*1000000 +DATEPART(hh,GETDATE())*10000 +DATEPART(mi,GETDATE())*100 +DATEPART(ss,GETDATE()) ) ; Yeah... I know what a lot of folks are thinking. "Big deal! 3.6 seconds v.s. 10.4 on 10 MILLION rows!
🌐
Spiceworks
community.spiceworks.com › programming & development › databases & queries
Oracle SQL – Convert Format of a Date to DD/MM/YYYY - Databases & Queries - Spiceworks Community
September 25, 2014 - I have a date ‘25-SEP-14’ and I would like to convert it to the format DD/MM/YYYY. I used the following: select TO_DATE(to_char(TO_DATE( to_char(‘25-SEP-14’),‘DD/MON/YY’)),‘DD/MON/YY’) from dual; It returns an error O…
🌐
Informatica Network
network.informatica.com › s › question › 0D56S0000AD70FbSQJ › help-to-convert-string-into-date
help to convert string into date
Loading · ×Sorry to interrupt · Refresh · Actions · Ask a Question · Contact Support · Terms of Use · Trademarks · Question Detail
🌐
Oracle
forums.oracle.com › ords › apexds › post › how-to-convert-datetime-to-yyyy-mm-ddthh-mi-ss-000-0000-so-2375
How to convert DateTime to YYYY-MM-DDTHH:MI:SS.000+0000 so that I can get records from table - Oracle Forums
April 28, 2021 - Hi, I looking for a help in converting the Timestamp to a string in the format YYYY-MM-DDTHH:MI:SS.000+0000 Background: I have a column Opt_Out_Time defined as a string and that stores the values in &...
🌐
TechOnTheNet
techonthenet.com › oracle › functions › to_date.php
Oracle / PLSQL: TO_DATE Function
... TO_DATE('2003/07/09', 'yyyy/mm/dd') ... Mar 15, 2002 · You could use the TO_DATE function with the dual table as follows: SELECT TO_DATE('2015/05/15 8:30:25', 'YYYY/MM/DD HH:MI:SS') FROM dual; This would convert the string value of 2015/05/15 8:30:25 to a date value...
🌐
Blogger
vadivel.blogspot.com › 2011 › 09 › convert-datetime-into-yyyymmddhhmmss.html
Convert Datetime into YYYYMMDDHHMMSS format
Converting Datatime value in YYYYMMDDHHMMSS format is not that complex as it sounds :) SELECT CONVERT(VARCHAR(10),GETDATE(),112) --Date ...