Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

DateAdd Expand / Collapse
Author
Message
Posted Monday, August 29, 2005 1:41 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, October 12, 2005 9:33 AM
Points: 29, Visits: 1

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

Post #215039
Posted Monday, August 29, 2005 1:43 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Thursday, January 16, 2014 12:03 PM
Points: 21,376, Visits: 9,594
SELECT TYPE,vendor,discontinueddate, datepart(quarter,[discontinueddate]) AS 'Quarter'
from dbo.EOL
WHERE DISCONTINUEDDATE > DateAdd(M,-24,GETDATE())
Order by Discontinueddate

Post #215041
Posted Monday, August 29, 2005 1:50 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, October 12, 2005 9:33 AM
Points: 29, Visits: 1

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

Post #215046
Posted Monday, August 29, 2005 1:55 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, April 11, 2014 1:57 PM
Points: 3,240, Visits: 491

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




Post #215050
Posted Monday, August 29, 2005 1:55 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Thursday, January 16, 2014 12:03 PM
Points: 21,376, Visits: 9,594
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
Post #215051
Posted Monday, August 29, 2005 2:09 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, October 12, 2005 9:33 AM
Points: 29, Visits: 1

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

 

Post #215057
Posted Monday, August 29, 2005 2:57 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, March 31, 2014 10:05 AM
Points: 2,553, Visits: 559
mike - isn't this the same as what is being discussed on this other thread..?!?!

other thread








**ASCII stupid question, get a stupid ANSI !!!**
Post #215077
Posted Monday, August 29, 2005 3:44 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, October 12, 2005 9:33 AM
Points: 29, Visits: 1

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.

Post #215095
Posted Monday, August 29, 2005 6:58 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, March 31, 2014 10:05 AM
Points: 2,553, Visits: 559
Hey Mike - no one's offended! Just double checking to make sure!







**ASCII stupid question, get a stupid ANSI !!!**
Post #215125
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse