Saturday, February 25, 2012

Date Format

I have a field with a datetime data type on it. I want
to run a query and return the datetime field in this
format (ex 21-JAN-2004). How can I do this?select replace(CONVERT(CHAR(11),GETDATE(),113),' ','-')
"Vic" <vduran@.specpro-inc.com> wrote in message
news:19be901c44d7c$049edca0$a501280a@.phx.gbl...
> I have a field with a datetime data type on it. I want
> to run a query and return the datetime field in this
> format (ex 21-JAN-2004). How can I do this?|||This worked!!! What does the 113 mean?
>--Original Message--
>select replace(CONVERT(CHAR(11),GETDATE(),113),' ','-')
>
>"Vic" <vduran@.specpro-inc.com> wrote in message
>news:19be901c44d7c$049edca0$a501280a@.phx.gbl...
>> I have a field with a datetime data type on it. I want
>> to run a query and return the datetime field in this
>> format (ex 21-JAN-2004). How can I do this?
>
>.
>|||Hi,
I have something close to it...it will return data as 21
Jan 2004 (without the dashes):
select convert(char(11), Column_name, 106) as Column_header
from Your-Table_Name
You can test this out and try different formats. Look up
cast and convert function in BOL.
hth
DeeJay
>--Original Message--
>I have a field with a datetime data type on it. I want
>to run a query and return the datetime field in this
>format (ex 21-JAN-2004). How can I do this?
>.
>|||Read the documentation on Books Online for CONVERT and you'll find the different style codes.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Vic" <vduran@.specpro-inc.com> wrote in message news:19b6601c44d9b$41f93fe0$a301280a@.phx.gbl...
> This worked!!! What does the 113 mean?
> >--Original Message--
> >select replace(CONVERT(CHAR(11),GETDATE(),113),' ','-')
> >
> >
> >"Vic" <vduran@.specpro-inc.com> wrote in message
> >news:19be901c44d7c$049edca0$a501280a@.phx.gbl...
> >> I have a field with a datetime data type on it. I want
> >> to run a query and return the datetime field in this
> >> format (ex 21-JAN-2004). How can I do this?
> >
> >
> >.
> >

No comments:

Post a Comment