Convert Text To Date Filter

ricky76ricky76 Member Posts: 204
I wondered if anyone could help me, i have a date filter on a report that i pass over to another report as text. With this i then want to automatically set the date filter on the second report. When i have it as text is there a quick way that i can convert this to a date filter so that i can select the max date from the filter?

Comments

  • BeliasBelias Member Posts: 2,998
    You can use:
    mytable.setfilter(mydatefield,dateAStext)
    
    if you have 12/03/07..31/12/07 in your date filter, you will filter your date field from 12/03/07 to 31/12/07
    ...or do you want to achieve something else? :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    See this Example..... Does this help you

    Name	                DataType	Subtype	
    ILE	                Record	Item Ledger Entry	
    DateFilterStrin           Text		
    Qty	                Integer		
    GLE	                Record	G/L Entry	
    
    //..................................................................................................
    
    GLE.reset;
    GLE.SETFILTER(GLE."Document Date",'%1..%2',010101D,010108D);  // putting  Filter on G/L Entry Rec
    if GLE.FINDSET then
      DateFilterString := GLE.GETFILTER("Document Date");
    MESSAGE('DateFilterString : %1',GLE.GETFILTER("Document Date"));
    
    
    Qty := 0;
    ILE.RESET;
    ILE.SETFILTER(ILE."Document Date",GLE.GETFILTER(GLE."Document Date"));   // Passing that Filter to ILE
    IF ILE.FINDSET THEN
      REPEAT
        Qty := Qty + ILE.Quantity;
      UNTIL ILE.NEXT= 0;
    MESSAGE('On Using GetFilter ....%1',Qty);
    
    
    Qty := 0;
    ILE.RESET;
    ILE.SETFILTER(ILE."Document Date",DateFilterString);   //  Passing the Datefilter String
    IF ILE.FINDSET THEN
      REPEAT
        Qty := Qty + ILE.Quantity;
      UNTIL ILE.NEXT= 0;
    MESSAGE('On Passing DateFilterString...%1',Qty);
    
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • bekiobekio Member Posts: 204
    Hi,

    I have a variable of type text DateFilterStr, and if I put 't' or 'w' ('t'- for TODAY, and 'w' for Work Date) and use this function

    "Salesperson/Purchaser".SETFILTER("Salesperson/Purchaser"."Date Filter",DateFilterStr);
    DateFilterStr:= "Salesperson/Purchaser".GETFILTER("Salesperson/Purchaser"."Date Filter");

    it doesn't displays the Today -t or Work Date -w, but it displays strange dates.

    Let's say that Today=15/11/2012, and Work Date =15/11/2012 , when i put in this field 't' it returns date 13/11/2012, when i put 'w' it returns date 14/11/2012. If i change the Work date to '01/01/2012', and pres 't' or 'w' it returns dates 27/12/2011 for 't' and 28/11/2011 for 'w'.

    DateFormat (dd/MM/yyyy)
    Any suggestions why?

    Thanks,
  • BeliasBelias Member Posts: 2,998
    sometimes it happens to me, too...i think that in some instances (don't ask me WHAT instances) NAV interpret t=tuesday and w=wednesday...correct?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • bekiobekio Member Posts: 204
    Thanks Belias,

    That's it. I have tested it to diferent dates, and it returns t=tuesday and w=wednesday within that week of Work Date.
    You can use all letter of day, or just the first letter. Also if you put 'Sunday' it returns date of that Sunday.

    strange!!! isn't?
  • BeliasBelias Member Posts: 2,998
    yeah, really strange, especially because it only happens from time to time. I would have expected the weird behavior to happen recursively every week, but it's not so. :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.