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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL date range of multiple fields

Status
Not open for further replies.

PROXI

Vendor
Sep 16, 2003
136
US
Ok... This is the code that I have so far.
Code:
SELECT borrower FROM New_main_info,Boarders
 WHERE Boarder=Employee
   AND Unumber=Environ("username")
UNION
SELECT borrower FROM New_main_info,Boarders
 WHERE prestacker=Employee
   AND Unumber=Environ("UserName")
UNION SELECT borrower FROM New_main_info,Boarders
 WHERE poststacker=Employee
   AND Unumber=Environ("UserName");

What I want to do is do a range for each on of the Selects'. for boarder it would be [date boarded], for prestacker it would be [date prestacked], for poststacker it would be [date stacked for postfunding] I would like to only have to input one set of date ranges (Enter Start Date: and Enter End Date:) if possible. If anyone has anything that they can contribute to help out I would appreciate it.

Thanks,

Thanks,

PROXI
 
Something like this ?[tt]
SELECT borrower FROM New_main_info,Boarders
WHERE Boarder=Employee
AND [date boarded] BETWEEN [Enter Start Date:] And [Enter End Date:]
AND Unumber=Environ("username")
UNION
SELECT borrower FROM New_main_info,Boarders
WHERE prestacker=Employee
AND [date prestacked] BETWEEN [Enter Start Date:] And [Enter End Date:]
AND Unumber=Environ("UserName")
UNION SELECT borrower FROM New_main_info,Boarders
WHERE poststacker=Employee
AND [date stacked for postfunding] BETWEEN [Enter Start Date:] And [Enter End Date:]
AND Unumber=Environ("UserName");[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
ok... I am trying to do it so that it shows the date it was done within the range and show the 3 fields... but it is only doing the date boarded section and stopping. Why
Code:
SELECT New_main_info.Borrower, New_main_info.Boarder, New_main_info.[Date Boarded], Boarders.Unumber
FROM New_main_info, Boarders
WHERE (((New_main_info.Boarder)=[Employee]) AND ((New_main_info.[Date Boarded]) Between [Enter Start Date:] And [Enter End Date:]) AND ((Boarders.Unumber)=Environ("username")))
union
SELECT New_main_info.Borrower, New_main_info.Prestacker, New_main_info.[Date Stacked], Boarders.Unumber
FROM New_main_info, Boarders
WHERE (((New_main_info.Prestacker)=[Employee]) AND ((New_main_info.[Date Stacked]) Between [Enter Start Date:] And [Enter End Date:]) AND ((Boarders.Unumber)=Environ("UserName")))
union
SELECT New_main_info.Borrower, New_main_info.Poststacker, New_main_info.[Date stacked for post funding], Boarders.Unumber
FROM New_main_info, Boarders
WHERE (((New_main_info.Poststacker)=[Employee]) AND ((New_main_info.[Date stacked for post funding]) Between [Enter Start Date:] And [Enter End Date:]) AND ((Boarders.Unumber)=Environ("UserName")));

Thanks,

PROXI
 
Have you tested each query individually ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I tried testing them and there is no data that shows at all in any of them. Would it matter that there is no join between the 2 tables?

There is the table new_main_info that houses the data. Another table called boarders contains the employees names and unumbers. Should there be a join here?

Thanks,

PROXI
 
Provided your table structure is the same as in your previous thread, the join are here:
WHERE (((New_main_info.Boarder)=[Employee])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
it is... the thing is that there are no rows showing in the query...( no white boxes even if blank)

Thanks,

PROXI
 
Obviously your network login (ie Environ("UserName")) match an Unumber with infos ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I found it... it has to be =Environ("username"), not just Environ("username")

:-
Thanks,

PROXI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top