May 27, 2008 at 12:17 pm
I have two columns in a table varDate and DDate. vardate is varchar(50) whereas DDate is of date data type.
vardate has dates in the format of e.g. 06-Sep-2008. I would like to update DDate column with the same date but in a different format. so in this case 06-Sep-2008 would become 06-09-2008 in DDate column.
can someone help me with the sql.
thanks
May 27, 2008 at 12:21 pm
Date formats are stored in a binary format, your client interprets that.
Look at CONVERT for the codes and formatting needed to get the dates into particular varchar formats.
May 27, 2008 at 12:23 pm
Using the date datatype does not provide formatting like that. You can use convert(varchar(15),date,113) which I believe is the ddmmyyyy format. Check cast and convert in BOL.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
May 27, 2008 at 5:16 pm
Implicit conversions will take care of it all... no formatting is necessary...
DECLARE @SomeDateCol DATETIME
SET @SomeDateCol = '06-Sep-2008'
SELECT @SomeDateCol
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply