SetFilter, DateTime

naranara Member Posts: 37
I am not very experienced in Navision, I need som help with a codeunit.
I am trying to get som item from item table and I will use the follwing filter

ItemRecord.SETFILTER("Last Date Modified", '>'+ Value);

If I send a Date (dd.mm.yyyy) as Value it will be OK but if I try to send a DateTiime( dd.mm.yyyy hh:mm:ss ) so it will not work.

How can I filter for DateTime?

Best Regards
Nasser

Comments

  • tinoruijstinoruijs Member Posts: 1,226
    You could use Date := DT2DATE(Datetime) and then use Date to filter your Date.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • krikikriki Member, Moderator Posts: 9,115
    The SETFILTER will be something like this:
    ItemRecord.SETFILTER("Last Date Modified",'>%1',DT2DATE(DateTime));
    or
    ItemRecord.SETFILTER("Last Date Modified",'%1..',DT2DATE(DateTime));

    The first does NOT include the date itself of "DateTime" and the second command DOES include the date.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • naranara Member Posts: 37
    I have another novice/stupid question.
    My Value parameter is Text[250], How can I convert to date time
    Is there any function that can do this for me
    If I use the following line, I will get error message in compile time
    ItemRecord.SETFILTER("Last Date Modified",'%1..',DT2DATE(Value));
    I mean is there any function like SQL Convert(DateTime, String, ....


    Best regards
    Nasser
  • DaveTDaveT Member Posts: 1,039
    Hi Nasser,

    Ths function you need is format( dateVariable );

    This is the simplest way to use the format command which can be used for more complex formatting of strings. Look it up on the Help->C/SIDE Reference Guide

    Don't worry we all had to learn at the start :wink:

    P.S. The reverse function i.e. from string to variable is EVALUATE - it took me a long time to find this when I started
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
Sign In or Register to comment.