Welcome to dbForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Displaying time from Datetime datatype

 
   Database Forums (Home) -> General Discussions RSS
Next:  a neophytish normalization question  
Author Message
Sreenivas

External


Since: Oct 30, 2008
Posts: 3



(Msg. 1) Posted: Thu Oct 30, 2008 10:11 pm
Post subject: Displaying time from Datetime datatype
Archived from groups: comp>databases>ms-sqlserver (more info?)

Hi every one,
I am new to sql server2005,I have datetime column
in my database ..I need to display only time part of the datetime .I
need to display in AM/PM format ..datetime is stored in this format mm/
dd/yyyy hh:mm:ss AM/PM .I need to display in this format hh:mm:ss AM/
PM ,How can i do that?? I searched for this on net but i got 24hour
format .
i tried this on my own ,but no hope!

Thanks in advance,

 >> Stay informed about: Displaying time from Datetime datatype 
Back to top
Login to vote
Sreenivas

External


Since: Oct 30, 2008
Posts: 3



(Msg. 2) Posted: Thu Oct 30, 2008 10:44 pm
Post subject: Re: Displaying time from Datetime datatype [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Oct 31, 10:39 am, Plamen Ratchev <Pla... RemoveThis @SQLStudio.com> wrote:
> The DATETIME data type does not have format but it is rather stored as
> binary value. Formatting is normally best done on the client side.
>
> In T-SQL you can use the CONVERT function with style 109 and a bunch of
> string manipulations to get the time formatted as string:
>
> SELECT RIGHT('0' +
>         LTRIM(STUFF(RIGHT(
>         CONVERT(CHAR(26), CURRENT_TIMESTAMP, 109)
>                       , 14),
>                     9, 4, ' ')),
>               11);
>
> --
> Plamen Ratchevhttp://www.SQLStudio.com

Plamen Ratchev..
Thanks a lot for your help

 >> Stay informed about: Displaying time from Datetime datatype 
Back to top
Login to vote
Plamen Ratchev

External


Since: Aug 20, 2008
Posts: 182



(Msg. 3) Posted: Fri Oct 31, 2008 1:39 am
Post subject: Re: Displaying time from Datetime datatype [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

The DATETIME data type does not have format but it is rather stored as
binary value. Formatting is normally best done on the client side.

In T-SQL you can use the CONVERT function with style 109 and a bunch of
string manipulations to get the time formatted as string:

SELECT RIGHT('0' +
LTRIM(STUFF(RIGHT(
CONVERT(CHAR(26), CURRENT_TIMESTAMP, 109)
, 14),
9, 4, ' ')),
11);

--
Plamen Ratchev
http://www.SQLStudio.com
 >> Stay informed about: Displaying time from Datetime datatype 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> General Discussions All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]