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
 General SQL Server Forums
 New to SQL Server Programming
 remove timestamp

Author  Topic 

kidaduo
Starting Member

45 Posts

Posted - 2008-04-08 : 14:50:40
Help.

How do u remove timestamp using select statement. Here is the list of records in my sql table

Datesent:
1:2008-01-18 00:00:19.000
2:2008-01-18 00:00:21.000
3:2008-01-18 00:00:24.000

I need to count these record and group them- If count and group them I will have three records for one count each for the date 2008-01-18. But I need to have one records with three count.

here is my sql.
SELECT datesent, COUNT(datesent) AS COUNT_RECORDS
from MyTable



Josephine

nr
SQLTeam MVY

12543 Posts

Posted - 2008-04-08 : 15:00:18
SELECT datesent = convert(varchar(8),datesent,112), COUNT(*) AS COUNT_RECORDS
from MyTable
group by convert(varchar(8),datesent,112)

you can also use
dateadd(dd,0,datediff(dd,0,datesent))

or many other methods


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

kidaduo
Starting Member

45 Posts

Posted - 2008-04-08 : 15:10:08
Thank you NR. Exceleent!

quote:
Originally posted by nr

SELECT datesent = convert(varchar(8),datesent,112), COUNT(*) AS COUNT_RECORDS
from MyTable
group by convert(varchar(8),datesent,112)

you can also use
dateadd(dd,0,datediff(dd,0,datesent))

or many other methods


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.



Josephine
Go to Top of Page
   

- Advertisement -