August 29, 2005 at 1:41 pm
Trying build this some that it will return 24 months from the current day. What am I doing wrong??
SELECT TYPE,vendor,discontinueddate, datepart(quarter,[discontinueddate]) AS 'Quarter'
from EOL
WHERE DISCONTINUEDDATE <DateAdd("M",24,GETDATE())
and (DISCONTINUEDDATE = '01/01/2005')
Order by Discontinueddate
Thanks
August 29, 2005 at 1:43 pm
SELECT TYPE,vendor,discontinueddate, datepart(quarter,[discontinueddate]) AS 'Quarter'
from dbo.EOL
WHERE DISCONTINUEDDATE > DateAdd(M,-24,GETDATE())
Order by Discontinueddate
August 29, 2005 at 1:50 pm
For some reason that makes it go from 2003 - 2009
I need current day plus 24 months so I can show 8 quarters of info at a time.
Thanks for the help.
Mike
August 29, 2005 at 1:55 pm
SELECT TYPE,vendor,discontinueddate, datepart(quarter,[discontinueddate]) AS 'Quarter'
from dbo.EOL
WHERE DISCONTINUEDDATE > DateAdd(M,-24,GETDATE()) and DISCONTINUEDDATE < DATEADD(D, 1, DATEDIFF(D, 0, GetDate()))
Order by Discontinueddate
August 29, 2005 at 1:55 pm
You say it goes from 2003 to 2009.
Run this:
SELECT GETDATE()
That will show you what the server's date is set as. If you are getting 2009, it looks like your system date is off.
Note that Remi's suggestion does NOT have the quotes around the M in the DATEADD function, where yours did. Remi's is the correct way of doing it. If you want 24 months earlier than GETDATE(), use the -24 otherwise make it 24.
-SQLBill
August 29, 2005 at 2:09 pm
I thought the same thing but it shows the correct date and time. It's my local PC<G>
Still getting a startdate of 2003 -24 and nothing on 24 or +24
The filed is a smalldatetime on SQL 2000 .
If I do WHERE (DISCONTINUEDDATE >= '01/01/2005') I get 01/01/2005 and up correctly as well.
Thanks for all of the help!!
Mike
August 29, 2005 at 2:57 pm
mike - isn't this the same as what is being discussed on this other thread..?!?!
**ASCII stupid question, get a stupid ANSI !!!**
August 29, 2005 at 3:44 pm
Yes I was asking the same thing. I though I should start a new thread since it was somthing different.
I appologize if it offended someone.
August 29, 2005 at 6:58 pm
Hey Mike - no one's offended! Just double checking to make sure!
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply