Wednesday, March 21, 2012

Date Manipulation

I'm trying to manipulate the date to return as 2/24/05 as opposed to
2/24/2005. So far I have this:
select GoodDate=substring(convert(varchar(12),g
etdate(),101),1,6)+
substring(convert(varchar(12),getdate(),
101),9,10)
Curious, is there a better way to achieve this?
The noob thanks you!
ChrisTry,
select convert(char(8), getdate(), 1)
AMB
"Ooroster" wrote:

> I'm trying to manipulate the date to return as 2/24/05 as opposed to
> 2/24/2005. So far I have this:
>
> select GoodDate=substring(convert(varchar(12),g
etdate(),101),1,6)+
> substring(convert(varchar(12),getdate(),
101),9,10)
> Curious, is there a better way to achieve this?
> The noob thanks you!
> Chris
>|||In a tiered architecture, display functions are done in the front end
and not in the database. The CONVERT() function is a proprietary way
to violate some basic relational design prinicples.
Standard SQL and just about everything else in IT is based on the
ISO-8601 formats. You might want to consider this before you use
ambigous display formats in the backend.|||Ahhh. Thank You!
Alejandro Mesa wrote:
> Try,
> select convert(char(8), getdate(), 1)
>
> AMB
>
> "Ooroster" wrote:
>

No comments:

Post a Comment