Gopal
Gopal

Reputation: 12012

Convert the Date Format

Using SQL Server 2005

Table1

ID Date

001 01/12/2010
002 15/12/2010
....

DateFormat: dd/mm/yyyy

I want to change the dateformat like mm/dd/yy by using select query

Select id, date from table1

Expected Output

ID Date

001 12/01/2010
002 12/15/2010
....

How to make a query for the above format.

Need Query Help.

Upvotes: 1

Views: 253

Answers (1)

Andomar
Andomar

Reputation: 238296

You can use convert to specify a mm/dd format, like 101:

select  CONVERT(varchar(30), YourColumn, 101)

If your table stores dates as a string, you'd have to convert the string to a date first, like:

select  CONVERT(varchar(30), CONVERT(datetime, YourColumn), 101)

Upvotes: 6

Related Questions