Tsql date column update

I have a date column that is in yyyy-mm-dd I want to convert it to dd/mm/yyyyy. The data type for this column is nvarchar(20) .I am willing to change the data type. The query i tried is

Update table1
set Column1= Convert(nvarchar(10),column1,101). 

It is executing but is not making any change.


You need to convert the value twice,

Update table1 
set Column1 = CONVERT(nvarchar(10),CONVERT(datetime, REPLACE(column1,'-','.'), 102), 103)

Your data is not really a date. It is currently a string, so Convert won't have any effect.

You would need to:

update table1 set Column1 = Convert(nvarchar(10), Convert(datetime, column1), 101)

but better still, you should consider changing the column data type to datetime, then converting it to the desired format when you select data from the table.

Need Your Help

C# ListView with CheckBoxes, automatic checkbox checked when multi select rows

c# winforms listview checkbox multi-select

I'm using a ListView control with multirow and fullrow select on. When I'm selecting multiple rows at once, some of my rows magically become checked. This happens when dragging the mouse over and...

How to timestamp an output artifact in Maven?

maven-2 maven maven-assembly-plugin maven-3

I am trying to find out if Maven has some built-in plug-in that can be used to time-stamp artifacts. I created an assembly file and am using the maven-assembly plugin to create a final distribution

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.