Options

Filtering dates

dulamandulaman Member Posts: 73
Hi all,

I have to establish this filter:

a) All the dates with a Starting Date equal or lesser than a given day
b) All the dates with an Ending Date equal or bigger than a given day
c) And... all the dates with a blank Ending Date

How should I perform this filter? My present code is:
SETFILTER("Starting Date", '<=%1', (MyDate));
SETFILTER("Ending Date", '>=%1|0D', (MyDate));

But it's not working :(

I'm sure this filter can be implemented but I wonder where's my fault.
-- dulaman
"I don't want to believe. I want to know." (Carl Sagan)

Answers

  • krikikriki Member, Moderator Posts: 9,120
    SETRANGE("Starting Date",0D,MyDate);  // the SETFILTER was not wrong, but SETRANGE is better
    SETFILTER("Ending Date", '>=%1|%2',MyDate,0D);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • lessilessi Member Posts: 33
    Try this :

    SETFILTER("Starting Date", '..%1', (MyDate));
    SETFILTER("Ending Date", '%1..|0D', (MyDate));

    I think it must works.
  • dulamandulaman Member Posts: 73
    Thank you very much kriki, your solution works fine! =D>

    lessi: your proposal gets this error msg:

    '0D is not a valid date'

    That was the same error I got before kriki enlightened our lives :)
    -- dulaman
    "I don't want to believe. I want to know." (Carl Sagan)
  • lessilessi Member Posts: 33
    I played, i loose.

    I beg your pardon, next time i will test before posting :?
  • krikikriki Member, Moderator Posts: 9,120
    lessi wrote:
    I played, i loose.

    I beg your pardon, next time i will test before posting :?
    No problem, most things I don't test either because I don't have the time.
    Sometimes someone else notices an error and corrects it. Or sometimes I have to try it anyway (when I have time) after the notice that it doesn't work (luckily it doesn't happen too much).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.