0
Sl,No  Name      BirthDay
1      Jojin1    2013-05-12 00:00:00.000
2      jojin2    2012-06-12 00:00:00.000
3      jojin3    2015-04-12 00:00:00.000

I have table called Datefunction. In that Birthday in above display format but I need DD/MM/YYYY. I try to convert below Query but Updating successful message, but check with Table not happening changes

UPDATE DateFunction
SET BirthDay = CONVERT(VARCHAR(15),BirthDay,103)
Ɖiamond ǤeezeƦ
  • 3,223
  • 3
  • 28
  • 40
vcbgvhgf
  • 3
  • 1
  • 2
  • 5
  • 3
    SQL Server stores dates in an internal manner that doesn't *have* a format. And this is a good thing. Do formatting in your presentation layer, not the database. – Damien_The_Unbeliever May 20 '13 at 08:51

2 Answers2

1

Firstly, I completely agree with Diamond GreezeR and Damein.

But having said that i know OP can't implement those things right now.

What you can do?

ALTER Table temp
ALTER column Datecolumn varchar(15)

update temp
set Datecolumn=CONVERT(VARCHAR(15),getdate(),103)
Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71
0

You cannot store the dates in that format, you can only display them.

SELECT CONVERT(varchar(10, BirthDay, 103)
FROM [Datefunction]

Other options (from my comments below):

  1. You could create a text field and store the result of the CONVERT function. See Luv's answer: https://stackoverflow.com/a/16646539/909882

  2. Another possibility is to use the DATEFORMAT option in SQL Server. However, I think this only sets the format for the session; it does not change it permanently.

  3. Also, you could could use SET LANGUAGE to choose the date format that SQL Server expects in queries. See stackoverflow.com/questions/1187127/… as an example

Community
  • 1
  • 1
Ɖiamond ǤeezeƦ
  • 3,223
  • 3
  • 28
  • 40
  • Ok This We can view the things. I need to update the table with Convert function, that I am asking ? – vcbgvhgf May 20 '13 at 09:31
  • You could create a text field and store the result of the `CONVERT` function. – Ɖiamond ǤeezeƦ May 20 '13 at 09:33
  • Another possibility is to use the `DATEFORMAT` option in SQL Server See MSDN: http://msdn.microsoft.com/en-us/library/aa259188(v=sql.80).aspx. However, I think this only sets the format for the session; it does not change it permanently. – Ɖiamond ǤeezeƦ May 20 '13 at 09:38
  • And my final suggestion is that you could could use SET LANGUAGE to choose the date format that SQL Server expects in queries. See http://stackoverflow.com/questions/1187127/sql-server-datetime-issues-american-vs-british as an example – Ɖiamond ǤeezeƦ May 20 '13 at 09:40
  • First We need to add one Column alter table Datefunction add NewDate varchar (30) After that below Query will update update DateFunction SET NewDate = CONVERT(char(10),BirthDay, 105) – vcbgvhgf May 20 '13 at 09:46
  • That's what [Luv](http://stackoverflow.com/a/16646539/909882) answered below and I suggested above. – Ɖiamond ǤeezeƦ May 20 '13 at 09:53