Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 24th, 2004, 07:59 PM
breggs breggs is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 0 breggs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Grouping by Date in DATETIME Field

Hi Guys,

I have a query like so:
SELECT creationDate, COUNT(custID) AS totalRegistered
FROM dbo.SecureSignInUser
WHERE (CreationDate BETWEEN '11/1/2004' AND '11/30/2004'
GROUP BY creationDate

What I want, is it to break the days of November down so it gives me the creationDate in terms of 11/1/2004, 11/2/2004 etc with a count of how many people were registered on that day.

e.g.
11/1/2004 - 3,604
11/2/2004 - 2,612
11/3/2004 - 1,543
11/4/2004 - 5,768

My problem is that creationDate is a DATETIME field so the date also has a time datepart so the results I get are as follows:

11/1/2004 00:00:00 - 604
11/1/2004 01:00:00 - 612

How do I do this so it is grouped only by the date and the time is totally ignored???? Thanking you for your help in advance.

Breggs

Reply With Quote
  #2  
Old November 25th, 2004, 10:11 AM
Salem Salem is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Dublin, Ireland
Posts: 157 Salem User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 10 m
Reputation Power: 6
SELECT convert(char(10), creationDate, 120), COUNT(custID) AS totalRegistered
FROM dbo.SecureSignInUser
WHERE (CreationDate BETWEEN '11/1/2004' AND '11/30/2004'
GROUP BY convert(char(10), creationDate, 120)

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Grouping by Date in DATETIME Field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway