December 15, 2003 at 3:42 am
I have a sql query like
select count(*) from GeneralBooks group by orderdate
where orderdate is a datetime column in the database table which stores the date and time, but when I execute the above the query it should only take into consideration the date part of the orderdate value and not consider the time part.
How do I separate it out, so that I can group by orderdate based only on the date and not time.
Thank you.
December 15, 2003 at 4:24 am
One way could be
SELECT
CONVERT(CHAR(10),MsgDatereceived,104) FROM mails_header
GROUP BY
CONVERT(CHAR(10),MsgDatereceived,104)
ORDER BY
CONVERT(CHAR(10),MsgDatereceived,104) DESC
I know M$ advocates using CAST, but this leaves you with less alternatives to format the date.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 15, 2003 at 9:58 pm
hello
anand
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply