Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Getting short

Author  Topic 

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-03-07 : 21:42:23
hi all

In my SP, i have a date column, whcih gives dates..
Unfortunately some dates are long dates(with time) and some are short(with dates)
How can i truncate this long date, to short in SP

Thanks in advance

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-07 : 21:51:26
i assume the date column is of datetime datatype ?

use dateadd(day, datediff(day, 0, datecol), 0) to remove the time.


KH

Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-03-07 : 21:57:33
Thanks for the reply.
Actually my select stmt in SP is like this

SELECT COUNT(dbo.Ship.[Ship Date]) AS ShipmentsCount, dbo.Ship.[Ship Date] AS [Ship Date]

i am getting ship date as
2007-01-02 00:00:00
i just want 2007-01-02

How can i add your idea here?
Thanks
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-07 : 21:59:26
why don't you do the formatting in your front end application ?


KH

Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-03-07 : 22:06:06
I also thought about that.
But we are displaying some charts from these sp.
so better if we can avoid time, and reduce the density of charts!!!!

IS this not possible in SP?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-07 : 22:18:25
yes. it is possible. use convert()

convert(varchar(10), datecol, 121)


KH

Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-03-07 : 22:26:56
Thanks
IT worked
GREAT HELP
Go to Top of Page
   

- Advertisement -