Command similar to SQL BETWEEN?

Mike_HWGMike_HWG Member Posts: 104
Is there syntax in NAV that operates similar to a SQL BETWEEN? Looking to do something like this:

IF mynumber BETWEEN 1 AND 10 THEN
DoStuff;


I thought I was able to do this before somehow using periods... :|
Michael Hollinger
Systems Analyst
NAV 2009 R2 (6.00.34463)

Answers

  • Mike_HWGMike_HWG Member Posts: 104
    OK I answered my question:

    IF mynumber IN [0..10] THEN
    DoStuff;


    However, I have a new question. Say I have the code below:


    mytext := '5';
    IF mytext IN THEN
    DoStuff;


    Is this a reliable way to do things, or do I need to cast the text into an integer?
    Michael Hollinger
    Systems Analyst
    NAV 2009 R2 (6.00.34463)
  • kinekine Member Posts: 12,562
    Do not forget that strings are sorted in different way than numbers. It is safer to evaluate the value into integer and than compare...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.