Skip to content Skip to sidebar Skip to footer

How To Use Convert Function In Sql Server?

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 Datefuncti

Solution 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?

ALTERTable temp
ALTERcolumn Datecolumn varchar(15)

update temp
set Datecolumn=CONVERT(VARCHAR(15),getdate(),103)

Solution 2:

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

SELECTCONVERT(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

Post a Comment for "How To Use Convert Function In Sql Server?"