MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 25th, 2004, 09:21 AM
dast's Avatar
dast dast is offline
web muppet
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: blackpool, uk
Posts: 47 dast User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 19 m 29 sec
Reputation Power: 5
Dateadd

Can any help me? I have a problem with this DATEADD function, its supposed to pull out entries for the next week. Can anyone spot what I'm doing wrong

" WHERE (tblContactLog.CallBackEmployee_id = " & Session("UserID") & ")" & _
" AND (tblContactLog.ContactLog_Complete <> 1)" & _
" AND (tblContactLog.ContactLog_CallBackDate < DATEADD(ww, 1, ContactLog_CallBackDate))" & _
__________________
"When I read about the evils of drinking, I gave up reading."

Reply With Quote
  #2  
Old March 25th, 2004, 02:18 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,343 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 5 m 22 sec
Reputation Power: 891
two things

first, you end with a concatenation (is there more to this query?)

second, you are testing

... AND (X < DATEADD(ww, 1, X))

which will find any date that is less than a week after itself??? i.e. none
__________________
r937.com | rudy.ca

Reply With Quote
  #3  
Old March 26th, 2004, 05:18 AM
dast's Avatar
dast dast is offline
web muppet
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: blackpool, uk
Posts: 47 dast User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 19 m 29 sec
Reputation Power: 5
Thanks for your help. Heres the full code, all I want to do is pull out entries for the next week for that user. Its basically a contact log. Any ideas!


set rs = objConn.execute("SELECT tblContactLog.*, tblContactLogType.ContactLogType_desc, " & _
" tblLeads.name, tblLeads.surname, tblLeads.lead_id, tblInternalEmployees.fullname" & _
" FROM tblContactLog" & _
" INNER JOIN tblContactLogType ON tblContactLog.ContactLogType_id = tblContactLogType.ContactLogType_id" & _
" INNER JOIN tblLeads ON tblContactLog.lead_id = tblLeads.lead_id" & _
" INNER JOIN tblInternalEmployees ON tblContactLog.InternalEmployee_id = tblInternalEmployees.user_id" & _
" WHERE (tblContactLog.CallBackEmployee_id = " & Session("UserID") & ")" & _
" AND (tblContactLog.ContactLog_Complete <> 1)" & _
" AND (tblContactLog.ContactLog_CallBackDate < DATEADD(ww, 1, ContactLog_CallBackDate))" & _
" ORDER BY " & _
" CASE " & _
" WHEN tblContactLog.ContactLog_Priority=1 THEN 0 " & _
" ELSE 1 " & _
" END, tblContactLog.ContactLog_CallBackDate ASC")

Reply With Quote
  #4  
Old March 26th, 2004, 06:45 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,343 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 5 m 22 sec
Reputation Power: 891
you are still doing the impossible:
Code:
AND (tblContactLog.ContactLog_CallBackDate 
< DATEADD(ww, 1, ContactLog_CallBackDate))
no matter what value ContactLog_CallBackDate has, it will never be less than one week later than itself

you might try
Code:
AND (tblContactLog.ContactLog_CallBackDate 
< DATEADD(ww, 1, getdate()))
but you will likely want something for the lower bound as well, since this would pull all rows from history as well

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Dateadd


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway