Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Problem, not pulling correct dates

Status
Not open for further replies.

WayneGretzky

Programmer
Jan 12, 2004
28
US
the portion of my query was working fine, nothing has changed except that I went from 30 to 20 for the dateadd function. Now when my query runs, I get CallDateTime that is not between the current time and 20 minutes prior, I get CallDateTime that is even from a month ago which is not right. Why now isn't it working when all I changed is the mi for minutes from 30 to 20? or is that not the problem?

....
AND CallDateTime between dateadd(mi, -20, GetDate()) and Getdate()
....

CallDateTime is of this format when viewing it in the results of Query Analyzer: 2005-12-28 14:29:19.983
If you absolutely need the whole query, just let me know, I assume though you can decifer what is wrong by my one line above taken from part of my query.
 
For me, dateadd is not an ANSI SQL function, so it seems you've posted in a wrong forum.
As you talk about Query Analyzer I guess you should post in one of the SQL Server fora.
 
Without seeing all of the information, it's a little hard to tell where the problem is.
Could you please post an example of the results you get from CallDateTime, Getdate(), dateadd(mi, -20, GetDate()), and dateadd(mi, -30, GetDate())? It might help isolate where the issue is.
 
I think I found it, I had 2 extra ) in an OR statement in my query.

Thanks though for replying.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top