Filter include
dulaman
Member Posts: 73
Hi all,
This should be an easy one. My head is buzzing and my eyes are rolling but I am so tired to find out the trick for this simple idea:
I need a filter to get all the dates that are equal or inferior than an given one OR all the dates that are equal or superior than the input.
It should be something like this:
SETFILTER("Starting Date", '>=%1|%2', myDate, 0D);
SETFILTER("Ending Date", '<=%1|%2', myDate, 0D);
But this pair of lines are not OR-ing but AND-ing!!
(excuse my --ehm-- neologisms)
What can I do??
This should be an easy one. My head is buzzing and my eyes are rolling but I am so tired to find out the trick for this simple idea:
I need a filter to get all the dates that are equal or inferior than an given one OR all the dates that are equal or superior than the input.
It should be something like this:
SETFILTER("Starting Date", '>=%1|%2', myDate, 0D);
SETFILTER("Ending Date", '<=%1|%2', myDate, 0D);
But this pair of lines are not OR-ing but AND-ing!!
(excuse my --ehm-- neologisms)
What can I do??
-- dulaman
"I don't want to believe. I want to know." (Carl Sagan)
"I don't want to believe. I want to know." (Carl Sagan)
0
Answers
-
Setfilter lines always AND, you need to use mark to mark the records. Try and find Mark, MarkOnly on this forum and you will find some examples on how to OR things for different fields.
Another is to use an extra field with the result of your calculation and filter on this extra flag.
Hope this helps
Danny0 -
Thank you Danny. I'm now trying something like this:
IF FIND('-') THEN REPEAT IF "Starting Date" >= myDate THEN MARK(TRUE); IF "Ending Date" <= myDate THEN MARK(TRUE); UNTIL NEXT = 0; MARKEDONLY(TRUE);
But it's not working at all. My report seems to fully ignore this piece of code! :roll:-- dulaman
"I don't want to believe. I want to know." (Carl Sagan)0 -
1) Where are you using this code?
2) Do not forget to 0D date0 -
Dulaman,
If you are using this in a report, I think that you best use CurrReport.SKIP in the OnAfterGetRecord to skip that record.
Please it in an if for your condition.
I don't know if the MARK procedure works inside a report ? #-o
Danny0 -
Hi kine
1) I'm using this code in a kinda "machine table" of my own. The machines start their use in a Starting Date and finish in a Ending Date. Now I need a report that tells me if in a given date that machine has been used. Of course if I enter, let's say, February 14th as myDate, but that machine started its use on 13th and finished on 16th, it should be included in my report as well. It should be included too those machines that have a Starting Date but not an Ending Date yet.
2) Oops! You are right!-- dulaman
"I don't want to believe. I want to know." (Carl Sagan)0 -
I mean in which trigger you entered this C/AL code... in the report in OnPreDataItem or elsewhere?0
-
Yep, on OnPreDataItem.
Let me recap...
I want that filter is ON when:
1) Starting Date = myDate OR
2) Ending Date = myDate OR
3) Starting Date < myDate AND Ending Date >= myDate OR
4) Starting Date < myDate AND Ending Date = 0D
Hope my purpose is clear now!-- dulaman
"I don't want to believe. I want to know." (Carl Sagan)0 -
It means, you want all records which are valid for the date you have in the variable?
If yes, it is easy... :-)SETFILTER("Starting Date",'<=%1|%2',MyDate,0D); SETFILTER("Ending Date",'>=%1|%2',MyDate,0D);
It means ("Starting Date" <= MyDate or "Starting Date" = 0D) AND ("Ending Date" >= MyDate or "Ending Date" = 0D) when I assume that "Starting Date<= "Ending Date" if both dates are <>0D.0 -
I KNEW it had to be easy!!
I was placing the wrong symbolzx%&&AAAGHHH!!! ](*,)
Thank you very much kine! =D>-- dulaman
"I don't want to believe. I want to know." (Carl Sagan)0 -
You are welcome... :-)
On this example you can see how is important to describe the problem in free text. The free text can tell us much more than some "mathematical" notation 8) (and can solve the problem just because you make clear what you want to do...
) 0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
