Format Date in SQL Server

go4expert's Avatar, Join Date: Aug 2004
Team Leader
I want to format the date of SQL server in the select statement but could not get it done.

What I want is something like TO_DATE, TO_CHAR in Oracle.
0
Amit Ray's Avatar, Join Date: Jul 2004
Contributor
Hello,

Check out the following links ....

MySQL Manual : Date and Time Functions

Formatting Dates in MySQL

Hope these will help ...

Cheers,
Amit Ray.
0
go4expert's Avatar, Join Date: Aug 2004
Team Leader
Quote:
MySQL Manual : Date and Time Functions

Formatting Dates in MySQL
Hey Amit I am looking for SQL Server stuff and not MySQL.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Hey Amit I am looking for SQL Server stuff and not MySQL.
I guess he mis read the query

Quote:
I want to format the date of SQL server in the select statement but could not get it done.
Hey you can use the convert function in SQL Server to achieve what you want.

Here is an example of how to use it.
Code:
SELECT convert(varchar,getdate()) FROM <tablename>
will show the output of current date in varchar format.
First parameter is the output data type wanted and second is the Field Name you want to format. Here I have used the current system date.

Thanks
Shabbir Bhimani
0
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Hey I just found this new thing with convert.

It takes a 3rd parameter where the output of date can be as in desired fashion.
http://msdn.microsoft.com/library/de...ca-co_2f3o.asp

Thanks
Shabbir Bhimani
0
go4expert's Avatar, Join Date: Aug 2004
Team Leader
Hey Guys. Thanks for all the help and convert really worked the way I wanted.
0
darsh999's Avatar
Light Poster
I think we have a option of change/remove the date over there in server !
Have u tried that ?