setrange for date...help

teckpoh
Member Posts: 271
hi all...
i want to gather a group of record from "item ledger entry" table whose "Posting Date" field is not later than work date..
mean..if workdate = '06/12/06' then all record must be after workdate. that is '07/12/06', or '08/12/06'....
so how to setrange for "Posting Date"
i tried to do tis but can't work.
setrange("Posting Date", '010100..%1',workdate);
setfilter("Posting Date", '010100..%1',workdate);
how to do setrange for date tat meet my criteria...????
i want to gather a group of record from "item ledger entry" table whose "Posting Date" field is not later than work date..
mean..if workdate = '06/12/06' then all record must be after workdate. that is '07/12/06', or '08/12/06'....
so how to setrange for "Posting Date"
i tried to do tis but can't work.
setrange("Posting Date", '010100..%1',workdate);
setfilter("Posting Date", '010100..%1',workdate);
how to do setrange for date tat meet my criteria...????
0
Comments
-
These are the ones you need:
SETRANGE("Posting Date",0D,workdate); // Up to a date
SETRANGE("Posting Date",FromDate,311299D); // From a date
Others are:
SETRANGE("Posting Date",workdate); // Just for one day
SETRANGE("Posting Date",FromDate,ToDate); // From a date to a Date
SETFILTER('%1|%2..%3',ThisDate,Fromdate,ToDate); //This day or That Day to another day
In the help there is also a &, although I have never used it in 10 years :shock:
SETFILTER('%1&%2..%3',ThisDate,Fromdate,ToDate); //This day and That
SETFILTER('%1&%2',FirstDate,SecondDate); // This day and That Day
Thinks thats will do you for a start!Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
Or for example:
SETFILTER("Posting date",'>%1',WORKDATE);
1 -
kine wrote:Or for example:
SETFILTER("Posting date",'>%1',WORKDATE);
Which is better or quicker :?:
SETRANGE("Posting Date",WORKDATE+1,311299D);
SETFILTER("Posting date",'>%1',WORKDATE);
:roll:
I think the difference in filtering is not noticable!Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
i fixed it already by using setfilter
eg:
setfilter("Posting Date",'%1..',workdate);
Anyways...10s for ur info...
God bless u~~0 -
David Cox wrote:kine wrote:Or for example:
SETFILTER("Posting date",'>%1',WORKDATE);
Which is better or quicker :?:
SETRANGE("Posting Date",WORKDATE+1,311299D);
SETFILTER("Posting date",'>%1',WORKDATE);
:roll:
I think the difference in filtering is not noticable!
No, there is not problem with performance, but with simplicity of code to be able to read it and understand it quickly... 8)
and SETRANGE("Posting Date",WORKDATE+1,311299D); will not work, because 311299 = 31.12.19990 -
and SETRANGE("Posting Date",WORKDATE+1,311299D); will not work, because 311299 = 31.12.1999
Yep your right it should be 31129999D not 311299D
31129999D is used in Navision's own code for 31 December 9999
Codeunit 11 Gen. Jnl.-Check Line for example.Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
teckpoh wrote:i fixed it already by using setfilter
eg:
setfilter("Posting Date",'%1..',workdate);
Anyways...10s for ur info...
God bless u~~
In your post you saidteckpoh wrote:if workdate = '06/12/06' then all record must be after workdate. that is '07/12/06', or '08/12/06'....
This includes the workdate does it not :?:
setfilter("Posting Date",'%1..',workdate);Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
David Cox wrote:and SETRANGE("Posting Date",WORKDATE+1,311299D); will not work, because 311299 = 31.12.1999
311299D is used in Navision's own code for 31 December 9999 #-o
The D at the end must make it 9999 :shock:
if you want 31.12.9999 you must use 31129999D -> it is same as when you enter it into date field on form...0 -
kine wrote:[
if you want 31.12.9999 you must use 31129999D -> it is same as when you enter it into date field on form...
Yep I just changed my other post! :oops:
But if you put in 01012006D then Navision chops it to 010106D when it compiles.
So what happens in 2106?, not that I will be around to worryAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
I am having purchase date information in sales invoice line . I created a form using the customer no, from date and to date i should get the sales of items purchased by the customer during the from date and to dates in sub form. where i should write code to update the sub form??0
-
if I want to set range for a document date before a specific date ( for example, document date before 01012017) how can i do this ?0
-
There are many API which you can use for this.
Check this out as well
https://rockwithnav.wordpress.com/2016/06/04/send-sms-dynamics-nav/Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/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