How can I apply a filter to a recordset through cal code, I tried something like this:
recordset.setfilter("date_field",date filter);
the error is triggered and says:
"Type conversion is not possible because 1 of the operators contains an invalid type
Text := Date"
i understood the errror that data-type is not compatible, however the date_field is not of type text but date only. How can I rectify this?
Another thing is that if the date specified is a dataformula like 01/01/07..12/31/07, how can I get the date '12/31/06' that is just a day before the specified filter. Please enlighten me.......
-Roshan Thapa
0
Comments
do the following
If you want to filter a date, there are a few options:
SETFILTER: use the way Albert showed you
I'm guessing you're stuck with this:
If you want to give a date filter through a request form, you can create a text variable, and OnValidate of the textbox: This way, you can give in 010107..311207 in the textbox (variable: txtDateFilter), and it'l make it 01/01/07..31/12/07 .
Why recSalesHeader? because you need a field to filter on (to use SETFILTER).
May be not a nice way to do it, but it is a way ...
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
2) to get the previous date use the CALCDATE function
PrevDate := CALCDATE('<-1Y>',GETRANGEMAX("Dater Filter"));
<Edit>
PrevDate := CALCDATE('<-1D>',GETRANGEMIN("Dater Filter"));
<End Edit>
Thankx guys(Albert and Waldo)
-Roshan
Can you be more specific? Example or something?
Don't forget you can use the virtual table "date" as well to do some date-tricks.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Did you sort out your compile error for incorrect date?
Thanks Waldo to you too.
without ur assistance, it would have been hard to solve my problem.....Thanx again
Can you put [solved] in the subject?
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Datefilter := recsalesheader.GETFILTER("Document Date");
lastdate := recsalesheader.GETRANGEMIN("Document Date");
lastdate := CALCDATE('<-1D>',lastdate);