August 29, 2005 at 9:09 am
I am trying to break down a date field into quarter and group by years. I can order by dates but I am having no luck find a howto on quarters. Any hint tips out there?
many thanks
Mike
August 29, 2005 at 9:23 am
Try researching DATEPART(quarter, DATEx) in BOL....
Good Hunting!
AJ Ahrens
webmaster@kritter.net
August 29, 2005 at 10:09 am
Thanks!
SELECT TYPE,vendor,discontinueddate, datepart(quarter, GETDATE()) AS 'Quarter'
from EOL
WHERE (DISCONTINUEDDATE >= '01/01/2005')
Order by discontinueddate
works and returns the Current quarter but how do I change the GETDATE to cover all years 2005 and above?
August 29, 2005 at 10:22 am
SELECT TYPE,vendor,discontinueddate, datepart(quarter,[discontinueddate]) AS 'Quarter'
from EOL
WHERE (DISCONTINUEDDATE >= '01/01/2005')
Order by Discontinueddate
Works!!!
August 29, 2005 at 12:49 pm
what if I need the quarters always 24 months from today everyday?
I tried using the DateAdd("m",24,Now());
But no luck
Hints??
August 29, 2005 at 2:39 pm
use getdate() instead of now(). and no need to quote the mm
select DateAdd(mm,24,getdate())
August 29, 2005 at 2:44 pm
or..just to take the tedium out of all this...
select DateAdd(yy, 2, getdate())
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply