This is a discussion on "GROUP BY and dates in SQL (again)" within the Databases section. This forum, and the thread "GROUP BY and dates in SQL (again) are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
GROUP BY and dates in SQL (again)
|
||
| Notices |
![]() |
|
|
LinkBack (1) | Thread Tools |
|
||||
|
GROUP BY and dates in SQL (again)
trying to using GROUP BY statement on a SQL Server DB.
GROUP BY [date] groups by date and time. Tried using the CONVERT function but no success... any tips?
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
|
|
|
|||
|
tried DATEPART()?
|
|
||||
|
this is what I've already tried:
CONVERT(DATETIME, [date], 5) ' 5: dd-mm-yy result: still returns time CONVERT(DATETIME, [date], 6) ' 6: dd mmm yy result: still returns time CONVERT(CHAR(12), [date], 5) ' 5: dd-mm-yy result: returns 'dd-mm-yy' but doesn't sort as a date, sorts alphabetically instead i.e.: date between 28-nov and 02-dec shows up in this order: 01 dec 04 02 dec 04 28 nov 04 29 nov 04 30 nov 04 I'm about to try datepart... I'll let you know
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
|
||||
|
great, I think I'm nearly there....
this worked: DatePart(dt, [date]) ' day of year but now I have to somehow display the actual dates because this makes much more sense: 30 orders on nov-27 than this: 30 orders on day 317
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
|
||||
|
GOT IT!
I used DATEPART to group by year and day and used CONVERT to return the date I want to display as a string. then I sort by year and day......... I'll post it in case somebody else comes across the same problem:
http://manuals.sybase.com/onlinebook...y=convert+date
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
![]() |
| Tags |
| group, dates, sql, again |
| Thread Tools | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.webforumz.com/databases/905-group-by-and-dates-in-sql.htm
|
||||
| Posted By | For | Type | Date | |
| Yamini's bookmarks tagged with | This thread | Refback | Nov 9th, 2006 15:29 | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP dates | simonb | PHP Forum | 11 | Sep 5th, 2007 14:30 |
| Days between 2 Dates | birdy247 | JavaScript Forum | 1 | Apr 19th, 2007 19:55 |
| dates in SQL | spinal007 | Databases | 3 | Nov 10th, 2004 09:32 |
| dates | benbacardi | Classic ASP | 2 | Sep 14th, 2004 16:18 |
| New to the Group | pahprints | Introduce Yourself | 8 | Jun 15th, 2004 21:52 |