problem with dates

roshanthapa
Member Posts: 90
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
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
-
Hi
do the followingrecordset.setfilter("date_field",'%1',date filter); or recordset.setfilter("date_field",'%1..%2',date1,date2);
0 -
Actually I am talking that date from a field in report. When I enter "010107..123107", the compiler says "is not a valid date". i also want to get the date of day before the period start date i.e. 123106.0
-
I don't understand exactly what you're trying to do.
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:recsalesheader.SETFILTER("Document Date",txtDateFilter); txtDateFilter := recsalesheader.GETFILTER("Document Date");
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 ...0 -
1) Check your date format maybe it's ddmmyy and not mmddyy
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>0 -
Thanx Waldo, this is exactly what I wanted to do. Now can we get the date of day before minimum range valued date? Since it is a text, I think calcfield won't work, will it?
Thankx guys(Albert and Waldo)
-Roshan0 -
CALCDATE and use GETRANGEMIN will work if you use the rec date field.
Did you sort out your compile error for incorrect date?0 -
Albert, I have solved my problem.////////////////THANX
Thanks Waldo to you too.
without ur assistance, it would have been hard to solve my problem.....Thanx again0 -
recsalesheader.SETFILTER("Document Date",Datefilter);
Datefilter := recsalesheader.GETFILTER("Document Date");
lastdate := recsalesheader.GETRANGEMIN("Document Date");
lastdate := CALCDATE('<-1D>',lastdate);0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions