March 15, 2010 at 9:59 am
What would be the most efficient way to bring back information for a certain number of days. ie you only want to see 30 days of information in the query
March 15, 2010 at 10:19 am
Use a date column from your table in the WHERE clause to limit the # of days you want to bring back.
March 15, 2010 at 10:22 am
John Rowan (3/15/2010)
Use a date column from your table in the WHERE clause to limit the # of days you want to bring back.
For example:
SELECT
oh.*
FROM
dbo.OrderHeader oh
WHERE
oh.OrderDate >= dateadd(dd, datediff(dd, 0, getdate()) - 30, 0);
March 15, 2010 at 10:29 am
Select
client_id as Client,
ApplicantFullName as ClientName,
CounselorName as Counselor,
lastapptdatetime,
tdate,
TUDCounselor,
TDDate,
FUD1,
FUD2,
FUD3,
FUD11,
FUD21,
FUD31
From PDT_Counselor_CO_View
where coalesce (complete,0) <>1 or coalesce(tud,0) <> 1
and tdate >= dateadd(dd, datediff(dd, 0, getdate()) - 30, 0)
Order by client_id desc
This is my query and I am trying to bring back only the last 30 days of info
March 15, 2010 at 10:32 am
Ittech03 (3/15/2010)
Selectclient_id as Client,
ApplicantFullName as ClientName,
CounselorName as Counselor,
lastapptdatetime,
tdate,
TUDCounselor,
TDDate,
FUD1,
FUD2,
FUD3,
FUD11,
FUD21,
FUD31
From PDT_Counselor_CO_View
where coalesce (complete,0) <>1 or coalesce(tud,0) <> 1
and tdate >= dateadd(dd, datediff(dd, 0, getdate()) - 30, 0)
Order by client_id desc
This is my query and I am trying to bring back only the last 30 days of info
Try this change to your where clause:
WHERE
(coalesce (complete,0) <> 1 or coalesce(tud,0) <> 1)
and tdate >= dateadd(dd, datediff(dd, 0, getdate()) - 30, 0)
March 15, 2010 at 12:01 pm
another issue, how would you get the date to not display a date if a check box is not checked
March 15, 2010 at 12:04 pm
Ittech03 (3/15/2010)
another issue, how would you get the date to not display a date if a check box is not checked
Sorry, don't understand the question. Please explain what you are attempting to do.
March 15, 2010 at 12:10 pm
I have field with that is assocaited with another field, when that field is selected I want to be able to bring that date back to another field
March 15, 2010 at 12:15 pm
Please see the article in my signature line and post an example of what you are looking for. This sounds easy enough, but we need to clearly understand what you are after. It's easiest to understand when we have example tables/data/resultsets.
Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply