How to format a date that looks like this yyyy-mm-dd in a table to mm-dd-yyy
y
in a view? What is the syntax?
Thanks
--
TSCONVERT(CHAR(10), ColumnName, 110)
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"TS" <TS@.discussions.microsoft.com> wrote in message
news:8B5B0627-00E9-4EFF-A23A-1EE1C03A85A9@.microsoft.com...
> How to format a date that looks like this yyyy-mm-dd in a table to
> mm-dd-yyyy
> in a view? What is the syntax?
> Thanks
> --
> TS|||Hi,
Use CONVERT funtion.
select convert(char(20),getdate(),101)
For a view use:-
Create view V1 as Select convert(char(20),column_name,101) AS Some_name from
Table_name
Thanks
Hari
SQL Server MVP
"TS" <TS@.discussions.microsoft.com> wrote in message
news:8B5B0627-00E9-4EFF-A23A-1EE1C03A85A9@.microsoft.com...
> How to format a date that looks like this yyyy-mm-dd in a table to
> mm-dd-yyyy
> in a view? What is the syntax?
> Thanks
> --
> TS|||Just to add some to the correct answers posted. SQL Server does not store
datetimes in any format that you would see as a datetime. It is two
Integers. Format is the result of the gui that you are displaying it in
given no other formatting such as CONVERT. See these for more details:
http://www.karaszi.com/SQLServer/info_datetime.asp Guide to Datetimes
http://www.sqlservercentral.com/col...sqldatetime.asp
Datetimes
http://www.murach.com/books/sqls/article.htm Datetime Searching
Andrew J. Kelly SQL MVP
"TS" <TS@.discussions.microsoft.com> wrote in message
news:8B5B0627-00E9-4EFF-A23A-1EE1C03A85A9@.microsoft.com...
> How to format a date that looks like this yyyy-mm-dd in a table to
> mm-dd-yyyy
> in a view? What is the syntax?
> Thanks
> --
> TS|||To prevent a 'next time'... ;)
http://msdn.microsoft.com/library/d...br />
2f3o.asp
ML|||Right, THIS will prevent a next time :)
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"ML" <ML@.discussions.microsoft.com> wrote in message
news:BCCDC6A4-FB90-46DD-9AD4-00D973CC59B6@.microsoft.com...
> To prevent a 'next time'... ;)
> http://msdn.microsoft.com/library/d... />
o_2f3o.asp
>
> ML
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment