November 4, 2009 at 11:56 am
I have a query that is not accepting GETDATE() . But when I hardcode today's date then it works fine .
Below is a sample of my query
select Columnnames
from tblA inner join tblB
on A.ID = B.ID and callbackdatetime >= '11/4/2009' and originalusername IN ('fbrewer','shester','kmillion','lbailey','pcaylor','twelby','yelghirai','edelao','jbrunson','pkoska','jwatts','dgonzalez','lkostopoulos','bwright','bsteinberg')
order by callbackdatetime,tblCampaignProspectsDetail.account,clients.clientname desc
Then it returns data for today's date .
Thanks,
November 4, 2009 at 12:02 pm
When you say "not accepting", what do you mean? That it gives you an error message, or that it doesn't give you the data you expect?
My first suspicion on the thing is that getdate() is not equal to '11/4/2009', because getdate() includes the current time. That means if the callback is scheduled for any time between midnight and less than one second ago, getdate() will consider it in the past and won't show it.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 4, 2009 at 12:07 pm
PSB (11/4/2009)
I have a query that is not accepting GETDATE() . But when I hardcode today's date then it works fine .Below is a sample of my query
select Columnnames
from tblA inner join tblB
on A.ID = B.ID and callbackdatetime >= '11/4/2009' and originalusername IN ('fbrewer','shester','kmillion','lbailey','pcaylor','twelby','yelghirai','edelao','jbrunson','pkoska','jwatts','dgonzalez','lkostopoulos','bwright','bsteinberg')
order by callbackdatetime,tblCampaignProspectsDetail.account,clients.clientname desc
Then it returns data for today's date .
Thanks,
Replace '11/4/2009' with dateadd(dd, datediff(dd, 0, getdate()), 0) and it should work.
November 4, 2009 at 12:30 pm
Thanks it worked when I used dateadd(dd, datediff(dd, 0, getdate()), 0) inplace of '11/4/2009'
November 4, 2009 at 12:54 pm
Thanks for the feedback. Now for a little follw-up. Do you understand what that bit of code is doing?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply