Tuesday, February 21, 2012

returning date without time part

Hi
I have a simple select like this
Select MyDate, MyID From Sales
The select is returning the date like this:
01/06/2005 12:00:00 a.m.
02/06/2005 12:00:00 a.m.
I'm showing it on a Datagrid in my app, my question is can I modify the
select to return only the date without the time part, like this
01/06/2005
02/06/2005
Thks.
Kenny M.If you're returning a datetime value, then no, you can't strip the date. if
you convert it to char, you can.
SELECT CONVERT(CHAR(10), MyDate, 101) AS MyDate, MyId FROM Sales
What you probably want to do, however, is set the format on the
GridColumnStyle in the client app so that it only displays the date.
"Kenny M." wrote:

> Hi
> I have a simple select like this
> Select MyDate, MyID From Sales
> The select is returning the date like this:
> 01/06/2005 12:00:00 a.m.
> 02/06/2005 12:00:00 a.m.
> I'm showing it on a Datagrid in my app, my question is can I modify the
> select to return only the date without the time part, like this
> 01/06/2005
> 02/06/2005
> Thks.
> --
> Kenny M.

No comments:

Post a Comment