Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 change mm\dd\yyyy to dd\mm\yyyy

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2010-09-13 : 16:52:40
Hi,

I have some dates which were imported incorrectly to sql server 2005.
Some dates appear as future dates. I need to find all dates which are in the future ie bigger than getdate and change the format to yyyy-mm-dd

so 2010-11-01 00:00:00.000 (1st Nov) will be changed to 2010-01-11 00:00:00.000

How can I achieve this?
Thanks

Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-13 : 16:53:47
What data type is it?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-14 : 05:29:17
You should use column with datetime datatype and update it with

set dateformat mdy
update table
set datecol=cast(col as datetime)

Also make sure to read this post
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-ii.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -