Go4Expert

Go4Expert (http://www.go4expert.com/)
-   SQL Server (http://www.go4expert.com/forums/sql-server-forum/)
-   -   Format Date in SQL Server (http://www.go4expert.com/forums/format-date-sql-server-t193/)

go4expert 8Nov2004 14:33

Format Date in SQL Server
 
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.

Amit Ray 8Nov2004 15:35

Re: Format Date in SQL Server
 
Hello,

Check out the following links ....

MySQL Manual : Date and Time Functions

Formatting Dates in MySQL

Hope these will help ...

Cheers,
Amit Ray.

go4expert 9Nov2004 09:19

Re: Format Date in SQL Server
 
Quote:

MySQL Manual : Date and Time Functions

Formatting Dates in MySQL
Hey Amit I am looking for SQL Server stuff and not MySQL.

shabbir 9Nov2004 09:26

Re: Format Date in SQL Server
 
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

Amit Ray 9Nov2004 10:23

Re: Format Date in SQL Server
 
Oops sorry .... for the various options with dates in SQL server you can look at the following links :

http://www.sqlteam.com/item.asp?ItemID=240

http://www.databasejournal.com/featu...0894_2197931_2

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=41292

http://expertanswercenter.techtarget...980070,00.html

http://expertanswercenter.techtarget...980072,00.html

Cheers,
Amit Ray.

shabbir 10Nov2004 16:09

Re: Format Date in SQL Server
 
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

go4expert 10Nov2004 16:12

Re: Format Date in SQL Server
 
Hey Guys. Thanks for all the help and convert really worked the way I wanted.

darsh999 14Oct2007 01:30

Re: Format Date in SQL Server
 
I think we have a option of change/remove the date over there in server !
Have u tried that ?


All times are GMT +5.5. The time now is 16:19.