Friday, February 24, 2012

Format Datetime in SQL syntax

Hi,
Does anyone know how I can format DateTme value in sql database to Short
DateTime using SQL syntax?
Thank you,
SunnyDo you mean you want to change the data type of the column from DateTime
to smalldatetime? Or you would like the returned results of a query to
have the datetime column with less information displayed.
Simon Worth
Sansanee wrote:
> Hi,
> Does anyone know how I can format DateTme value in sql database to Short
> DateTime using SQL syntax?
> Thank you,
> Sunny
>|||To change the ACTUAL datatype persisted (stored) in the database, use the
Cast operator, but ensure that all the actual date values are between 1 jan
1900 and 6 Jun 2079.
If you just want to format the output of a query, (and you can;t or don't
want to o this on client) you can use Convert() function and convert to a
varchar(), using one of a group of various format types Look up COnvert in
Books OnLine...
"Sansanee" wrote:

> Hi,
> Does anyone know how I can format DateTme value in sql database to Short
> DateTime using SQL syntax?
> Thank you,
> Sunny
>
>|||I recommend you check out:
http://www.karaszi.com/SQLServer/info_datetime.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Sansanee" <sansanee@.nospam.com> wrote in message news:elIrk2xNFHA.3880@.tk2msftngp13.phx.gb
l...
> Hi,
> Does anyone know how I can format DateTme value in sql database to Short
> DateTime using SQL syntax?
> Thank you,
> Sunny
>|||Thank you. It works!
Sunny
"CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
news:56BDBAEA-F16B-4447-9145-E70699BE6AEC@.microsoft.com...
> To change the ACTUAL datatype persisted (stored) in the database, use the
> Cast operator, but ensure that all the actual date values are between 1
jan
> 1900 and 6 Jun 2079.
> If you just want to format the output of a query, (and you can;t or don't
> want to o this on client) you can use Convert() function and convert to a
> varchar(), using one of a group of various format types Look up COnvert in
> Books OnLine...
>
> "Sansanee" wrote:
>

No comments:

Post a Comment