setrange for date...help

teckpohteckpoh 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...????

Comments

  • David_CoxDavid_Cox Member Posts: 509
    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! :lol:
    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.com
  • kinekine Member Posts: 12,562
    Or for example:
      SETFILTER("Posting date",'>%1',WORKDATE);
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • David_CoxDavid_Cox Member Posts: 509
    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:
    :lol:

    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.com
  • teckpohteckpoh Member Posts: 271
    i fixed it already by using setfilter
    eg:

    setfilter("Posting Date",'%1..',workdate);

    Anyways...10s for ur info...
    God bless u~~
  • kinekine Member Posts: 12,562
    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:
    :lol:

    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.1999 :D
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • David_CoxDavid_Cox Member Posts: 509
    edited 2006-12-07
    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.com
  • David_CoxDavid_Cox Member Posts: 509
    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 said
    teckpoh 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.com
  • kinekine Member Posts: 12,562
    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:
    No... try to do MESSAGE('%1',FORMAT(311299D,0,4)); :-)

    if you want 31.12.9999 you must use 31129999D -> it is same as when you enter it into date field on form...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • David_CoxDavid_Cox Member Posts: 509
    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 worry :lol:
    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.com
  • dynamics navdynamics nav Member Posts: 50
    edited 2016-07-26
    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??
  • lamislamis Member Posts: 46
    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 ?
  • RockWithNAVRockWithNAV Member Posts: 1,139
    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/
Sign In or Register to comment.