08-18-2007 1:56 PM
Hi Guys,
<u>My Query is :</u>
select * from DSR where d1 between Log1 and Log2
d1 is given by us as input.
I am checking d1 in between Log1 and Log2.
Is there any possibility that if I give date range like d1 to d2, it has to check all the dates between d1 and d2 one by one in the Log1 & Log2 range and it has to return all the records which are matching with the dates between d1 & d2.
Do I need to put any loop here for each and every date.
Please help me out in this. thanks
Venkat.
08-19-2007 11:22 AM
Hi
if you declare S_DATE field as Select-options
generally we check this against a single field as
SELECT...FROM...VBAK...
WHERE AUDAT IN S_DATE.
here it seems it has to be checked by both log1 and log2 dates
then you can use
select * from DSR where
LOG1 >= S_DATE-low and LOG2 <= S_DATE-high.
provided both LOW and HIGH of date fields are netered on selection screen.
<b>Reward points for useful Answers</b>
Regards
Anji
08-20-2007 1:49 PM
Hi Anji Reddy,
I am very thankful to you for your reply.
I am writing the same query in SQL Server, I dont have select-options over there like in ABAP. what to do now for my query.
Please try to solve my problem bcoz i am struck up with this from last four days.
I am not able to continue my project. Please helpl out.
Thank you sir,
Venkat.
08-19-2007 3:06 PM
If Log1 and Log2 are your database field names and d1 and d2 are the input date values from the user, you need to do something like:
SELECT * FROM dsr
WHERE log1 BETWEEN d1 AND d2
AND log2 BETWEEN d1 AND d2 .
The first item in the where block is the field name, this is followed by the condition to apply for the selection.
Andrew
08-20-2007 10:25 AM
i think u have to handle five cases separately......
1) d1 < log1 and d2< log1 - then no value will be fetched.
2) d1 <log1 and (d2 between log1 and log2)
3)d1> log2 and d2> log2 - then no value will be fetched.
4) (d1 between log1 and log2) and d2 > log2
5) d1 >log1 and d2 <log2
6) d1< log1 and d2> log2
reward if helpful.
08-20-2007 1:51 PM
Hi Suman sir,
I am very thankful to you for your reply.
I am writing the same query in SQL Server, I dont have select-options over there like in ABAP. what to do now for my query.
Please try to solve my problem bcoz i am struck up with this from last four days.
I am not able to continue my project. Please helpl out.
Thank you sir,
Venkat.
08-20-2007 3:34 PM
if d1<= d2
select * from DSR where
LOG1 >= d1 and LOG2 <= d2.
endif.
is it working?????