Format varchar date (1 Viewer)

reggiete

Registered User.
Local time
Today, 04:46
Joined
Nov 28, 2015
Messages
56
Hello all,

I am trying to format a varchar column which as dates in the format of '09152016'. I would like to convert the text date to 09/15/2016.
 

reggiete

Registered User.
Local time
Today, 04:46
Joined
Nov 28, 2015
Messages
56
hello ridder, i am using SQL server and i get the 'Format' is not a recognized built in function.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 22:46
Joined
Jan 20, 2009
Messages
12,849
The link is about converting from date formats rather than from a string.

You will need to get the parts of the date using Left() and Substring() then convert to date. If you have Server 2012 or later, you can then use DateFromParts() which is the SQL version of Access DateSerial(). Otherwise concatenate the parts you extract into a standard date string (yyyy-mm-dd) and Convert() from that to Date.
 

Users who are viewing this thread

Top Bottom