Sunday, February 19, 2012

DateFormat

I have a column of effDate, its format likes this 2004-05-04 11:37:26.783, I
need get data from effData is 2004-05-04.
How do I trunc effDate to yyyy-mm-dd format. I just started to learn TSQL.
Thanks for your help
SELECT CONVERT(CHAR(10), effDate, 23) FROM <tablename>
http://www.aspfaq.com/
(Reverse address to reply.)
"Sally" <Sally@.discussions.microsoft.com> wrote in message
news:05CDD692-5B69-45B5-B9CE-86FE97D76C5F@.microsoft.com...
> I have a column of effDate, its format likes this 2004-05-04 11:37:26.783,
I
> need get data from effData is 2004-05-04.
> How do I trunc effDate to yyyy-mm-dd format. I just started to learn TSQL.
> Thanks for your help
|||What is the datatype for the column? If it is datetime or smalldatetime, then you either need to format it in
the client application, or return as a string, using the CONVERT function and specify a suitable format code
for the 3:rd parameter of that function. This and more, you can read in:
http://www.karaszi.com/SQLServer/info_datetime.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Sally" <Sally@.discussions.microsoft.com> wrote in message
news:05CDD692-5B69-45B5-B9CE-86FE97D76C5F@.microsoft.com...
> I have a column of effDate, its format likes this 2004-05-04 11:37:26.783, I
> need get data from effData is 2004-05-04.
> How do I trunc effDate to yyyy-mm-dd format. I just started to learn TSQL.
> Thanks for your help

No comments:

Post a Comment