how to convert all mm/dd/yyyy dates to yyyy-mm-dd using SQL SERVER 2008?? [Resolved]

Posted by Laghaterohan under Sql Server on 1/23/2011 | Points: 10 | Views : 1719 | Status : [Member] | Replies : 3
Hello,

I have around 700 rows in the database whose date is in the format mm/dd/yyyy however, i need to convert all these days to yyyy-mm-dd format..Can any one please let me know how can i do this for all 700 rows at one go?

Please suggest...its urgent...


Thanks!!

Best Regards,
Rohan Laghate



Responses

Posted by: PandianS on: 1/24/2011 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
Hi

Could you please try this...
DECLARE @A DATETIME

SELECT @A = '01/24/2011'
SELECT CONVERT(VARCHAR,@A,120)
2011-01-24 00:00:00


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/24/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

You can get the format as Mr pandian refered in the above reply.

If you want to get the date alone without time stamp then use the below code

SELECT CONVERT(VARCHAR(10), GETDATE(), 120) AS [YYYY-MM-DD]

SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 111), '/', '-') AS [YYYY-MM-DD]


Thanks
Karthik
www.f5Debug.net

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 1/24/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks a lot! :)

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response