Sunday, February 19, 2012

DATE CONVERSION

How to convert DATE from one format to another.
datatype: datetime
original format: 2006-09-25 10:48:19.000
I need to convert to 2006-09-25
any TSQL function? I want to do this in a single SQL query. The above
date value can be NULL as well. If it is null, It should no do
anything.
Thanks.
Hi,
You could use CONVERT function.
select convert(char(10),getdate(),20)
Thanks
hari
SQL Server MVP
<krallabandi@.gmail.com> wrote in message
news:1158939304.788022.14330@.i42g2000cwa.googlegro ups.com...
> How to convert DATE from one format to another.
> datatype: datetime
> original format: 2006-09-25 10:48:19.000
> I need to convert to 2006-09-25
> any TSQL function? I want to do this in a single SQL query. The above
> date value can be NULL as well. If it is null, It should no do
> anything.
> Thanks.
>

No comments:

Post a Comment